Home

1000+ C Programming Multiple Choice Question Answer [Solved]

Thursday 9th of March 2023

Sharing is caring

1. Which options shows the correct hierarchy of arithmetic operators
A. **, * or /, + or -
B. **, *, /, +, -
C. **< /< *< +<-
D. / or *, - or +
Answer : D
2. the value *(&i) is same as printing the value of address of i.
A. True
B. False
C.
D.
Answer : B
3. 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
4. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
5. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
6. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
7. 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
8. 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
9. 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
10. 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
11. The output of the following code is:
main() 
{
int a = 5, b = 6;
(a == b? printf("%d", a));
}

A. 0
B. 5
C. Error
D. None of the above
Answer : C
12. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
13. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
14. The output of the following code is:
void main() 
{
int a;
int &b = a;
a=100;
printf("b=%d\ta=%d
", b,a);
}

A. b=100 a=100
B. b=100 a=0
C. b=0 a=100
D. Error
Answer : D
15. The same variable names of automatic type can be used in different functions without any conflict.
A. True
B. False
C.
D.
Answer : A
16. What does STL stand for?
A. Simple Template Library
B. Standard Template Library
C. Static Type Library
D. Single Type-based Library
Answer : A
17. Which escape character can be used to beep from speaker in C?
A. \a
B. \b
C. \m
D.
Answer : A
18. What would be the output of the following program?
int x=40;
main(){
int x=20;
printf("
%d",x);
}

A. 40
B. 20
C. Compilation Error
D. Garbeg Value
Answer : B
19. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
20. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
21. All elements of a structure are allocated contiguous memory locations.
A. True
B. False
C.
D.
Answer : A
22. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
23. 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
24. Only one break can be used in one loop.
A. True
B. False
C.
D.
Answer : B
25. unsigned' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
26. The output of the following code is:
main() 
{
int k, num = 30;
k = (num > 5 ? (num <= 10 ? 100 : 200) : 500);
printf("
%d", num);
}

A. 200
B. 500
C. 30
D. Unpredictable
Answer : C
27. Which one of the following is not a valid reserved keyword in C++
A. Explicit
B. Public
C. Implicit
D. Private
Answer : C
28. 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
29. The output of the following code is:
void main() 
{
char a = 'B';
switch (a)
{
case 'A' : printf("a");
case 'B' : printf("b");
default : printf("c");
}

A. B
B. b
C. bca
D. bc
Answer : D
30. Which classes allow primitive types to be accessed as objects?
A. Storage
B. Virtual
C. Friend
D. Wrapper
Answer : B
31. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
32. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
33. 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
34. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
35. A function to be called must be ended with a----------------
A. .
B. ?
C. ;
D. none of the above
Answer : C
36. 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
37. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
38. fprintf()function can be used to write into console.
A. True
B. False
C.
D.
Answer : B
39. Which of the STL containers store the elements contiguously (in adjecent memory locations)?
A. std::vector
B. std::list
C. std::map
D. std::set
Answer : C
40. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
41. 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
42. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
43. Structures within structures cannot be created.
A. True
B. False
C.
D.
Answer : B
44. 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
45. When a user defined function is defined in program, then it has to be called at least once from the main().
A. True
B. False
C.
D.
Answer : B
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. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
48. C is a ___ language
A. High Level and Procedural
B. Low Level and OOPS
C. Middle Level and Procedural
D. Machine Level and OOPS
Answer : A
49. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
50. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A

Sharing is caring