Home

C Programming MCQ Solved Paper for RRB JE

Thursday 9th of March 2023

Sharing is caring

1. The expression "b = 3 ^ 2;" will evaluate b = 9.
A. True
B. False
C.
D.
Answer : B
2. 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
3. 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
4. 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
5. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
6. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
7. 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
8. Which of the following keyword supports dynamic method resolution?
A. abstract
B. Virtual
C. Dynamic
D. Typeid
Answer : A
9. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A
10. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
11. When is std::bad_alloc exception thrown?
A. When new operator cannot allocate memory
B. When alloc function fails
C. When type requested for new operation is considered bad<  thisexception is thrown
D. When delete operator cannot delete teh allocated (corrupted) object
Answer : D
12. Right shifting an operand 1bit is equivalent to multiplying it by 2.
A. True
B. False
C.
D.
Answer : B
13. 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
14. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
15. Which one of the following is not a fundamental data type in C++
A. float
B. string
C. int
D. wchar_t
Answer : A
16. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
17. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
18.

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
19. 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
20. Which options shows the correct hierarchy of arithmetic operators
A. **, * or /, + or -
B. **, *, /, +, -
C. **< /< *< +<-
D. / or *, - or +
Answer : D
21. 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
22. /* The C language.
/* is a procedural language .*/*/
The above statement is valid.

A. True
B. False
C.
D.
Answer : B
23. 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
24. enum helps to create user defined datatype.
A. True
B. False
C.
D.
Answer : A
25. What's wrong? while( (i < 10) && (i > 24))
A. the logical operator && cannot be used in a test condition
B. the while loop is an exit-condition loop
C. the test condition is always true
D. the test condition is always false
Answer : D
26. 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
27. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
28. 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
29. 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
30. 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
31. The output of the following code is:
void main()
{
int z, a = 5, b = 3; z = a * 2 + 26 % 3;
printf("%d", z); }

A. 10
B. 0
C. 12
D. None of the above
Answer : C
32. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
33. Only one break can be used in one loop.
A. True
B. False
C.
D.
Answer : B
34. 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
35. 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
36. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
37. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
38. 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
39. What is the difference between overloaded functions and overridden functions?
A. Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding
B. Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called a overloaded fucntion.
C. Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding
D. Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden fucnion.
Answer : B
40. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
41.

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
42. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
43. Which one of the following is not a valid reserved keyword in C++
A. Explicit
B. Public
C. Implicit
D. Private
Answer : C
44. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
45. 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
46. It is necessary to initialize the array at the time of declaration.
A. True
B. False
C.
D.
Answer : B
47. fopen() function returns a pointer to the open file.
A. True
B. False
C.
D.
Answer : A
48. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
49. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
50. 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

Sharing is caring