Interview Q & A 4
Ques 1. what happens for the below code since the array subscrit is more
than the size of the array?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[3] ={3,4,5};
arr[5]=4343;
}
options:
A. The arr[5] hold the value no issue.
B. Some valid data will be overwritten and the program may crash.
C. compiler error
D. the array size increases
Ques 2. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m=1, n=1;
for(; m; printf("%d %d\n", m++, n), m=n++<=2);
return 0;
}
options:
A. 1 1 1 2 1 3
B. 1 1 2 2 3 3
C. 2 1 3 2 4 2
D. 1 1 0 2 0 3
Ques 3. which of the below options is correct about the uart communication?
options:
A. Uart reads the buffer register and transmit data in parallel.
B. Transmit data in buffer register, UART adds start bit, parity, stop bits to the data, then tranmit data in parallel.
C. Transmit data in buffer register, UART adds start bit, parity, stop bits to the data, then tranmit data in parallel.
D. Transmit data in buffer register, UART adds start bit, parity, stop bits to the data, then tranmit serially.
Ques 4. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
enum color{red, green, blue}s;
printf("%d\n",sizeof(s));
return 0;
}
options:
A. 2
B. 4
C. 1
D. 8
Ques 5. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x=1, y=3, z=8, m=0, n=2;
x = (x || (y=z)) && (m || (y=n));
printf("%d %d %d %d %d",x,y,z,m,n);
return 0;
}
options:
A. 1 2 0 8 2
B. 1 0 2 2 8
C. 1 2 8 0 2
D. 0 2 2 1 8
Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int add( int x, int y)
{
return x+y;
}
int sub( int x, int y)
{
return x-y;
}
int mul( int x, int y)
{
return x*y;
}
int divide( int m, int n)
{
return m/n;
}
int (*f[4])(int x, int y)={add, sub, mul,divide};
int main()
{
int x=3, y=2, i;
for(i=0; i<=3; i++)
printf("%d ", (*f[i])(x, y));
return 0;
}
options:
A. compiler error
B. 5 1 6 1
C. runtime error
D. 5 1 6 1.5
Ques 7. what are the features of the function?
- code is more readable.
- testing the code is easier
- recursive call can be done for functions
- each functionality can be kept seperately
Ques 8. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int * fun();
int main() {
int *q;
q=fun();
printf("%d",*q);
return 0;
}
int * fun() {
int g=25;
g--;
g--;
return &g;
}
options:
A. 23
B. 25
C. compiler error
D. runtime error
Ques 9. How the build process happens in c program?
options:
A. Preprocessing, compilation, linking
B. compilation, Preprocessing, linking
C. linking, Preprocessing , compilation
D. none of the above
Ques 10. when we found the undefined function error while building the c program?
options:
A. linking
B. preprocessing
C. compilation
D. none of the above
Ques 11. using volatile keyword for the below code is valid ?
#include <stdio.h>
#include <stdlib.h>
volatile int m=3;
int main() {
int h=3,i;
for(i=0; i<5; i++)
h=m;
return 0;
}
options:
A. since it is in loop not valid
B. it is valid the value of m may change
C. it gives compiler error
D. none of the above
Ques 12. if one wants to transmit data to 4 receivers within the distance of 50 feet with a speed of 6mbs
so which protocol is suitable for this?
options:
A. rs232
B. rs245
C. rs422
D. rs485
Ques 13. which of the following is correct?
options:
A. SPI speed is lesser than I2C and UART
B. SPI uses the chip select signals to select the slaves
C. Multi master is possible in SPI communication
D. SPI will communicate with one slave
Answers
1. B
2. A
3. D
4. B
5. C
6. B
8. D
9. A
10. A
11. B
12. C
13. B