Home

RBI Grade B officer - C Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. 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
2. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
3. In the expression - 'x + y + 3z =20'
A. x + y' is a keyword
B. 3 and 20 are constants
C. 3z is a constant
D. y is a variable and z is a constant
Answer : B
4. A function to be called must be ended with a----------------
A. .
B. ?
C. ;
D. none of the above
Answer : C
5. 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
6. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
7. 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
8. Each pass through a loop is called a/an
A. enumeration
B. iteration
C. culmination
D. pass through
Answer : C
9. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
10. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
11. 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
12. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
13.

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
14. 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
15. 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
16. 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
17. Every if statement can be converted into an equivalent switch statement.
A. True
B. False
C.
D.
Answer : B
18. void' is a datatype.
A. True
B. False
C.
D.
Answer : A
19. 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
20. = and = = have the same operation.
A. True
B. False
C.
D.
Answer : B
21. Character data types cannot be declared as unsigned.
A. True
B. False
C.
D.
Answer : B
22. 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
23. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A
24. continue statement is used
A. to go to the next iteration in a loop
B. come out of a loop
C. exit and return to the main function
D. restarts iterations from beginning of loop
Answer : D
25. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
26. 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
27. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
28. Which of the following keyword supports dynamic method resolution?
A. abstract
B. Virtual
C. Dynamic
D. Typeid
Answer : A
29. printf() is not a library function.
A. True
B. False
C.
D.
Answer : B
30. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
31. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
32. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
33. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A
34. unsigned' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
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. 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. && and & operators have the same meaning.
A. True
B. False
C.
D.
Answer : B
38. How many times the following loop will execute?
for (a = 0; a < 4; a++)
printf("hello
");

A. 3
B. 4
C. 5
D. infinite
Answer : B
39. p++ executes faster than p + 1.
A. True
B. False
C.
D.
Answer : A
40. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
41. Which escape character can be used to beep from speaker in C?
A. \a
B. \b
C. \m
D.
Answer : A
42. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
43. 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
44. 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
45. 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
46. gets() and puts() are unformatted I/O functions.
A. True
B. False
C.
D.
Answer : A
47.

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
48. Operation between an integer and float always yields a float result.
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. Which of the following is not an infinite loop
A. int i =1;
while (1)
{i++;}
B. for( ; ; );
C. int true=0< false;
while (true)
{false = 1;}
D. int y, x = 0;
do
{y = x;}
while (x==0);
Answer : C

Sharing is caring