Home

1000+ C Programming MCQ for GMAT [Solved]

Thursday 9th of March 2023

Sharing is caring

1. The default initial value of automatic storage class is 0.
A. True
B. False
C.
D.
Answer : B
2. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
3. If 'str' is a string of 7 characters, the statement printf("%4s", str); will display ------characters.
A. 4
B. 7
C. 6
D. 0
Answer : A
4. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
5. The function fopen() on failure returns---------------------.
A. 0
B. NULL
C. 1
D. none of the above
Answer : B
6. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
7. The same variable names of automatic type can be used in different functions without any conflict.
A. True
B. False
C.
D.
Answer : A
8. A C variable cannot start with
A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
Answer : D
9. What is right way to Initialization array?
A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;
B. int n{} = { 2, 4, 12, 5, 45, 5 } ;
C. int n{6} = { 2< 4< 12 } ;
D. int n(6) = { 2, 4, 12, 5, 45, 5 } ;
Answer : A
10. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
11. The output of the following code is:
main() 
{
int a = 0;
for (; i = 0; i++)
printf("%d", a);
}

A. 0
B. Nothing will be displayed
C. Infinite loop
D. None of the above
Answer : D
12. The output of the following code is:
main() 
{
void msg()
{
printf("HELLO WORLD");
}
}

A. HELLO WORLD
B. Error
C. None of the above
D. Null
Answer : B
13. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * ?
B. * ? / +
C. + ? / *
D. * / + -
Answer : D
14. Operation between an integer and float always yields a float result.
A. True
B. False
C.
D.
Answer : A
15. && and & operators have the same meaning.
A. True
B. False
C.
D.
Answer : B
16. A recursive function calls itself again and again.
A. True
B. False
C.
D.
Answer : A
17. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
18. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
19. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
20. What does STL stand for?
A. Simple Template Library
B. Standard Template Library
C. Static Type Library
D. Single Type-based Library
Answer : A
21. p++ executes faster than p + 1.
A. True
B. False
C.
D.
Answer : A
22. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
23. Which options shows the correct hierarchy of arithmetic operators
A. **, * or /, + or -
B. **, *, /, +, -
C. **< /< *< +<-
D. / or *, - or +
Answer : D
24.

What will be output if you will compile and execute the following c code?


#include 
int main(){
char c=125;
c=c+10;
printf("%d",c);
return 0;
}

 


A. 135
B. +INF
C. -121
D. -135
Answer : C
25. strcat() function ----------------------- two strings.
A. delete
B. concatenate
C. compare
D. none of the above
Answer : B
26. The output of the following code is:
int f(int a, int b); 
void main()
{
int a = 12, b=154;
printf("%d", f(a, b));
}
int f(int a, int b)
{
if (a<b) return(f(b, a));
if(b==0) return(a);
return (f(b, a % b));
}

A. 2
B. 1
C. Compilation error
D. Runtime error
Answer : A
27. The output of the following code is:
void change (char *k) 
{
k="Hello";
return;
}
main()
{
char *ch = "World";;
change(ch);
printf("%s", ch);
}

A. Hello
B. World
C. Compilation error
D. Hello World
Answer : B
28. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A
29. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
30. printf("%d", sizeof('2')); will print 2.
A. True
B. False
C.
D.
Answer : B
31. A continue statement causes execution to skip to
A. the return 0; statement
B. the first statement after the loop
C. the statement following the continue statement
D. the next iteration of the loop
Answer : C
32. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
33. A multidimensional array A[10][9] can store-------- number of elements
A. 91
B. 88
C. 90
D. 89
Answer : C
34. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
35. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
36. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
37. Union is used to hold different data at different time.
A. True
B. False
C.
D.
Answer : A
38. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
39. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
40. Character data types cannot be declared as unsigned.
A. True
B. False
C.
D.
Answer : B
41. struct stud
{
int roll;
char name[20];
float marks;
} *p;
What will be the byte size of p?

A. 24
B. 2
C. 26
D. None
Answer : B
42. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
43. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
44. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
45. Which of the following is not true about preprocessor directives
A. They begin with a hash symbol
B. They are processed by a preprocessor
C. They form an integral part of the code
D. They have to end with a semi colon
Answer : A
46. The -------------------------- loop executes at least once.
A. for
B. while
C. do-while
D. while & do-while
Answer : C
47. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
48. The output of the following code is:
void main() 
{
static int a = 1, b, c;
if (a>=2) b=2; c=3;
printf("%d\t%d", b,c);
}

A. 2 3
B. 0 3
C. 0 0
D. 2 0
Answer : B
49. The output of the following code is:
void main() 
{
float a;
int x = 10, y = 3; a = x / y;
printf("%f", a); }

A. 3.999999
B. Error
C. 3
D. 3.000000
Answer : D
50. The output of the following code is:
void main() 
{
int a = 1, b=2;
int *ip;
ip=&a;
b=*ip;
printf("%d", b);
}

A. 2
B. 1
C. 100
D. 0
Answer : B

Sharing is caring