Upload
rsnayak438093689
View
16
Download
1
Embed Size (px)
DESCRIPTION
C Technical Test Unit 4 and 5
Citation preview
** Pre-Placement Paper : Technical Total Question : 40 Time : 30 Min
1. What is output:#include <stdio.h>int main(){
printf(“%d>>%d”,8>>1,4>>1);return 0;
}A) 1 B) 2 C) 4 D)8
2. …….. operator is suitable for putting on a particular bit in a number.
3. Bitwise operator is used to perform operations at ………………………….level .
4. Dynamic memory allocation function available are………….. (a) malloc(). (b) calloc().
(c) both(a)&(b) (d) none5. All static variables are automatically initialized to …………
(a) 0 (b) 1 (c) -1 (d)Both (a) & (b)
6. #include <stdio.h>intmain()
{enum color {red,green,blue};typedefenam color mycolor;mycolor m=red;printf(“%d”,m);return 0;
}A) 1 B) 0 C) red D) error
7. state the statement :a) If malloc() successfully allocate memory then it return s the number of bytes
it has allocated.b) malloc() returns a NULL if it fails to allocate requested memory.c) Bitwise | operator can be used to set multiple bits in a number.d) Bitwise & operator can be used to check if more than one bit in a number is on.
A) TTTF B) FTTT C) TFTF D) FFTT
8. Which of the following is the correct prototype of the malloc() function in c?A) int * malloc(size int);B) char *malloc (char);C) void malloc();D) void * malloc(size_t);
9. C automatically converts any intermediate values to the proper type without loosing any significance.
(a) Implicit conversion. (b) Explicit conversion.(c) both(a)&(b). (d) none.
10. A Microprocessor having 16 bit CPU register can hold …………..(a) int (b) float/double(c) both(a)&(b). (d) none
11. What is output :#include <stdio.h>int main(){
typedefintarr[5];arriarr ={1,2,3,4,5}; int x;for(x=0;x<4;x++)printf(“%d ”,iarr[x]);}
A) 1 2 3 4 B) 1 2 3 4 5 C) Error D) No output
12. Bitwise OR Oprerator is used to Turn On a Particular bit.(a) true. (b)false
13. State the statement :a) Every c program will contain at least one preprocessor directive.b) A header file contains macros, structure declarations and function prototypes.c) A preprocessor directive is a message from programmer to a preprocessor.d) A preprocessor directive is a message from compiler to linker.
A) TTFF B) FTTF C) FTFT D) TFFT
14. Value stored in a CPU register can always be accessed faster than the one who stored in memory.
(a) true (b)false
15. Valid examples of #define statements are :a) #define MAX 200 b) #define X=2.5c)#define N 5, M 10 d) Both (a) & (b)
16. What is output :#include <stdio.h>#define PRINT(int) printf(“%d”,int)int main(){int x=2;PRINT(x);}
A) 2 B) 0 C) Error D) No output
17. #define statements must be end with a semicolon.(a) True (b) False
18. What is output :#include <stdio.h>int main(){
printf(“%x\n”,-1<<3);}
A) Ffff B)fff8 C) 0 D) No output
19. Valid examples of const statements are :(a) constint MAX 50 (b) constintclass_size =40;
(c) const ARRAY 11 (d) None
20. Lacal variable which is stored in the ………………(a) auto (b) static (c) extern (d) register
21. …….. operator is suitable for turning off a particular bit in a number.
22. main(){
int k=0;k&=~(1<<5);
printf("%x\t",k); k|=(1<<2);printf("%x\t",k);k^=(1<<14);printf("%x\n",k); }a. 0, 14, 4004 b. 4,0,404 c. 0,4,4004 d. None of these
23. main() {inti,bit, num=0x238E;unsignedint mask;for(i=5;i>0;i--) {mask<<1;
bit=(num&mask)>>i;
printf("%d",bit);
}a. 00012 b. compilation error c. 0000012 d. Run time error
24. Global variable known to all functions in the file.(a) auto (b) register (c) extern (d) static
25. What are the way of storing data in file………………………………………………………..
26. Local variable which exists and retains its value even after the control is transferred to the calling function.
(a) auto (b) register (c) extern (d) static27. typedef can create a new file.
(a) True (b) False28. The symbol of Token passing operator is
(a) & (b) # (c) $ (d) ##29. The symbol of Stringizing operator is
(a) & (b) # (c) $ (d) ##30. All preprocessor directives begin with…………….
(a) & (b) # # (c) ## (d)#31. Bitwise operators may not be applied to ….…………
(a) int and float (b) float and double (c) int and char (d) int and double32. The symbol of bitwise left shift operator is
(a) >> (b) <<< (c) ^ (d) None
33. #define A -2 #define B -100main(){int ratio=A/B; printf("%d ",ratio);}a. -2 b. 2 c. 0 d. compilation error
34. #define MAN(x, y) ((x)>(y)) ? (x):(y);int main() {
int i=, j=5, k=0; k = MAN(++i, j++);printf("%d, %d, %d\n", i, j, k);}a. Compilation error b. 1,7,6 c. 0, 0, 0 d. garbage value
35. #define SQUARE(x) x*xint main(){float s=0, u=0, t=0, a; a = 2*(s-u*t)/SQUARE(t);printf("Result = %f", a);}a. Compilation error b. -1.#IND00 c. garbage value d. none
36. #define JOIN(s1, s2) printf("%s=%ccccs %s=%s%d \n", #s1, s1, #s2, s2);int main(){char *str1="Mca";char *str2="Third";JOIN(str1, str2);}a. Str1= mca str2= third b. str1=cccs str2=third0c. str1=cccs str2=Third0 d. garbage value
37. #define PRINT(int) printf("int=d, ", int);int main(){int x=2, y=3, z=4; PRINT(x); PRINT(y);PRINT(z);}a. 2,3,4 b. 0, 0 ,0 c. d,d,d d. garbage value
38. #define FUN(i, j) i##jint main(){int va1=10;int va12=20;printf("%d\n", FUN(va1, 2)); }a. 0 b. 20 c. 16. D. compilation error
39. #define FUN(arg) do\{\\if(arg)\printf("MCA STUDENT...", "\n");\}while(--i)int main(){int i=2;FUN(i<3);}a. MCA STUDENT b. MCA STUDENT MCA STUDENT c. compilation eror d. None of these
40. If the file to be included doesn't exist, the preprocessor flashes an error message.
a. true b. false