Home

1000+ C Programming Multiple Choice Question Answer [Solved]

Thursday 9th of March 2023

Sharing is caring

1. What is an array?
A. An array is a collection of variables that are of the dissimilar data type.
B. An array is a collection of variables that are of the same data type.
C. An array is not a collection of variables that are of the same data type.
D. None of the above.
Answer : B
2. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
A. the question mark should be an equal sign
B. the first semicolon should be a colon
C. there are too many variables in the statement
D. the conditional operator is only used with apstrings
Answer : D
3. Which of the following correctly describes C++ language?
A. Statically typed language
B. Dynamically typed language
C. Both Statically and dynamically typed language
D. Type-less language
Answer : D
4. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * ?
B. * ? / +
C. + ? / *
D. * / + -
Answer : D
5. perror( ) function used to ?
A. Work same as printf()
B. prints the error message specified by the compiler
C. prints the garbage value assigned by the compiler
D. None of the above
Answer : B
6. The output of the following code is:
main() 
{
int sub[50];
for(i=0; i<=48;i++)
{
sub[i]=i;
printf("
%d", sub[i]);
}
}

A. 0 to 48 will be displayed
B. 48
C. 49
D. Compilation Error
Answer : D
7. A multidimensional array A[10][9] can store-------- number of elements
A. 91
B. 88
C. 90
D. 89
Answer : C
8. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
9. No commas or blanks are allowed within an integer or a real constant.
A. True
B. False
C.
D.
Answer : A
10. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
11. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
12. The output of the following code is:
main() 
{
int a[10], i;
for (i = 1; I <= 0; i++)
{
scanf("%d", a[i]);
printf("%d", a[i]);
}
}

A. 10
B. Logical error
C. Runtime error
D. 1 to 10 will be displayed
Answer : B
13. The output of the following code is:
void main()
{
int a = 20;
printf("%d\t%d
", ++a, a);
}

A. 21 21
B. 20 21
C. 21 20
D. 20 20
Answer : C
14. What will be output if you will compile and execute the following c code?
#include 
int main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
return 0;
}

A. Less than
B. Equal
C.

Greater than


D. None of above
Answer : A
15. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
16. gets() and puts() are unformatted I/O functions.
A. True
B. False
C.
D.
Answer : A
17. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
18. Every if statement can be converted into an equivalent switch statement.
A. True
B. False
C.
D.
Answer : B
19. Which of the following is not recommended in a header file?
A. Type definitions (typedefs)
B. Class definitions
C. Function definitions
D. Template definitions
Answer : D
20. Only one break can be used in one loop.
A. True
B. False
C.
D.
Answer : B
21. fprintf()function can be used to write into console.
A. True
B. False
C.
D.
Answer : B
22. The output of the following code is:
#define sqr(x= x*x) 
main()
{
int a = 10, b = 5;
printf("%d, %d", sqr(a+b),sqr(++a));
}

A. 77, 121
B. 225, 121
C. 77< 144
D. Compilation error
Answer : D
23. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
24. strcat() function ----------------------- two strings.
A. delete
B. concatenate
C. compare
D. none of the above
Answer : B
25. p++ executes faster than p + 1.
A. True
B. False
C.
D.
Answer : A
26.

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


#include 
#define x 5+2
int main(){
int i;
i=x*x*x;
printf("%d",i);
return 0;
}



A. 27
B. 343
C. 233
D. Compiler Error
Answer : A
27. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
28. What is Keywords?
A. Keywords have some predefine meanings and these meanings can be changed.
B. Keywords have some unknown meanings and these meanings cannot be changed.
C. Keywords have some predefine meanings and these meanings cannot be changed.
D. None of the above
Answer : C
29. Which of the following is an example of compounded assignment statement?
A. a = 5
B. a += 5
C. a = b = c
D. a = b
Answer : C
30. What will be output if you will compile and execute the following c code?
#include 
int main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
return 0;
}

A. 1
B. 64
C. 320
D. Compiler Error
Answer : B
31. Which of the following is a valid destructor of the class name "Country"
A. int ~Country()
B. void Country()
C. int ~Country(Country obj)
D. void ~Country()
Answer : B
32. What is the right way to access value of structure variable book{ price, page }?
A. printf("%d%d", book.price, book.page);
B. printf("%d%d", price.book, page.book);
C. printf("%d%d"< price::book< page::book);
D. printf("%d%d", price?>book, page?>book);
Answer : A
33. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
34. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
35. Nested macros are allowed.
A. True
B. False
C.
D.
Answer : B
36. What's wrong? for (int k = 2, k <=12, k++)
A. the increment should always be ++k
B. the variable must always be the letter i when using a for loop
C. there should be a semicolon at the end of the statement
D. the commas should be semicolons
Answer : B
37. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
38. C programs are converted into machine language with the help of
A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer : B
39. Which of the following expressions is wrong
A. float a =123.56;
B. char ch ='T' * 'A';
C. char ch ='T' *20;
D. 3 +a = b;
Answer : D
40. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
41. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
42. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
43. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
44. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)?
A. const X* const
B. X* const
C. X*
D. X&
Answer : D
45. The -------------------------- loop executes at least once.
A. for
B. while
C. do-while
D. while & do-while
Answer : C
46. The output of the following code is:
main() 
{
unsigned int a = 10;
while (a>=10)
{
int a; a-- ;
}
printf("%i", a);
}

A. Infinite loop
B. 9
C. 0
D. None
Answer : A
47.

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
48. All elements of a structure are allocated contiguous memory locations.
A. True
B. False
C.
D.
Answer : A
49. enum helps to create user defined datatype.
A. True
B. False
C.
D.
Answer : A
50. The-------------------- statement helps immediate exit from any part of the loop
A. break
B. continue
C. exit
D. All of the above
Answer : A

Sharing is caring