MCQ Question On C Programming
MCQ Question On C Programming
1 Which preprocessor directive is used to include the standard input-output header file?
A) #import <stdio.h>
B) #include <stdlib.h>
C) #define <stdio.h>
D) #include <stdio.h>
A) To define constants
B) To include header files
C) To declare functions
D) To initialize variables
A) #include
B) void
C) {
D) all of the above
Explanation: Tokens in C can be keywords, identifiers, constants, strings, operators, etc. All the options
provided are valid tokens in C.
6 What will the following sequence represent: +-?
Explanation: The sequence +- is considered a single token representing the unary plus and unary minus
operators.
7 Which of the following is not a valid identifier in C?
A) _variableName
B) 123variable
C) Var_Name
D) variableName
Answer: B) 123variable
8 What is the significance of the token EOF in C?
A) End Of File
B) Error Or Fault
C) End Of Function
D) Equal Or False
Explanation: EOF stands for End Of File in C, indicating the end of a file while reading.
9 What is the significance of the backslash (\) token in C?
Explanation: In C, the backslash (\) is used as an escape character to represent special characters within
string literals.
10 What will be the output of the following code snippet:
#include <stdio.h>
int main() {
int a = 5, b = 10;
printf("%d", a b);
return 0;
}
A) Compilation error
B) Runtime error
C) Output: 510
D) Output: 5
#include <stdio.h>
int main() {
int a = 5, b = 10;
printf("%d", a,b);
return 0;
}
A) Compilation error
B) Runtime error
C) Output: 510
D) Output: 5
#include <stdio.h>
int main() {
int a = 5, b = 10;
printf("%d", (a,b));
return 0;
}
A) Compilation error
B) Runtime error
C) Output: 5
D) Output: 10
Answer: D) Output: 10
13 Which of the following is NOT a keyword in C?
A) extern
B) auto
C) declare
D) static
Answer: C) declare
14 Which keyword is used to define a constant in C?
A) define
B) constant
C) const
D) final
Answer: C) const
15 Which keyword is used to define a function that returns no value?
A) void
B) null
C) none
D) nil
Answer: A) void
16 Which of the following is NOT a storage class keyword in C?
A) static
B) dynamic
C) register
D) auto
Answer: B) dynamic
17 Which keyword is used to exit from a loop prematurely?
A) leave
B) stop
C) exit
D) continue
Answer: D) continue
18 Which keyword is used to define a variable that can be accessed across different files?
A) public
B) shared
C) extern
D) global
Answer: C) extern
19 What will happen if you use a keyword as an identifier in C?
A) No effect
B) Compile-time error
C) Runtime error
D) Warning message
#include <stdio.h>
int main() {
printf("%d", sizeof(char));
return 0;
}
A) 2
B) 4
C) 1
D) 8
Answer: C) 1
21 What is the output of the following program?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++);
printf("%d", ++x);
return 0;
}
A) 56
B) 57
C) 67
D) 77
Answer: B) 57
22 What will the code snippet below output?
#include <stdio.h>
int main() {
int i = 10;
printf("%d", i++ + ++i);
return 0;
}
A) 21
B) 22
C) 23
D) 24
Answer: B) 22
23 What does the following code output?
#include <stdio.h>
int main() {
int x = 3;
printf("%d", x << 1);
return 0;
}
A) 3
B) 6
C) 1
D) 2
Answer: B) 6
24 What will the output of the program be?
#include <stdio.h>
int main() {
int i = 5;
printf("%d %d", i++, i);
return 0;
}
A) 5 5
B) 6 5
C) 5 6
D) 6 6
Answer: C) 5 6
25 What is the output of the following code?
#include <stdio.h>
int main() {
int a = 5;
int b = 2;
printf("%d", a / b);
return 0;
}
A) 2
B) 2.5
C) 2.0
D) 3
Answer: A) 2
26 What does the following program output?
#include <stdio.h>
int main() {
char ch = 'A' + 1;
printf("%c", ch);
return 0;
}
A) A
B) B
C) C
D) None of the above
Answer: B) B
27 What is the output of the program below?
#include <stdio.h>
int main() {
int x = 3;
printf("%d", x-- + x++);
return 0;
}
A) 6
B) 5
C) 7
D) 4
Answer: B) 5
Identifiers
28 Which of the following is a valid identifier in C?
A) 123Name
B) _myVariable
C) myVariable$
D) My Variable
Answer: B) _myVariable
29 How many characters can an identifier in C have?
A) 31
B) 63
C) 79
D) Unlimited
Answer: D) Unlimited
30 Which of the following is not allowed as an identifier in C?
A) main
B) double
C) 123main
D) MyMain
Answer: C) 123main
31 Which identifier is a legal variable name in C?
A) VariableName
B) _Variable
C) $variable
D) 2Variable
Answer: B) _Variable
32 What will happen if a reserved keyword is used as an identifier in C?
A) No effect
B) Compilation error
C) Runtime error
D) Warning message
A) #define VALUE 10
B) #include <stdio.h>
C) #ifdef MAIN
D) #undefine DEBUG
int main() {
int 123variable = 10;
printf("%d", 123variable);
return 0;
}
What will happen when you try to compile and run this code?
int main() {
int x = 5, X = 10;
printf("%d %d", x, X);
return 0;
}
What will be printed?
A) 5 10
B) 10 10
C) 5 5
D) Compilation Error
Answer: A) 5 10
37 What will the following program output?
#include <stdio.h>
#define MAX 100
int main() {
int max = 50;
printf("%d", max + MAX);
return 0;
}
A) 150
B) 50
C) 100
D) Compilation Error
Answer: A) 150
38 Consider the code:
#include <stdio.h>
int main() {
int myVariable = 5;
printf("%d", MYVARIABLE);
return 0;
}
What will be printed?
A) 5
B) Garbage Value
C) Compilation Error
D) 0
#include <stdio.h>
int main() {
int num_1 = 10;
int num_2 = 20;
printf("%d", num_1num_2);
return 0;
}
A) 1020
B) 30
C) Compilation Error
D) Runtime Error
#include <stdio.h>
int main() {
int _var = 10;
printf("%d", _var);
return 0;
}
A) 10
B) Compilation Error
C) Runtime Error
D) Garbage Value
Answer: A) 10
41 Given the program:
#include <stdio.h>
int main() {
int 123abc = 5;
printf("%d", 123abc);
return 0;
}
What will be the result?
A) Compilation Error
B) 5
C) Garbage Value
D) 123
#include <stdio.h>
int main() {
int myVariable = 10;
int MYvariable = 20;
printf("%d", myVariable + MYvariable);
return 0;
}
A) 20
B) 30
C) 10
D) Compilation Error
Answer: B) 30
43 Consider the code:
#include <stdio.h>
int main() {
int var1 = 5;
int var2 = 5;
printf("%d", var1 + var2);
return 0;
}
What will the output be?
A) 10
B) 55
C) Compilation Error
D) 5
Answer: A) 10
Data Types
44 Which of the following is not a valid data type in C?
A) long
B) double
C) boolean
D) float
Answer: C) Boolean
45 What is the size of the float data type in C on a typical 32-bit system?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 16 bytes
Answer: B) 4 bytes
46 Which data type is used to store a single character in C?
A) char
B) int
C) byte
D) float
Answer: A) char
47 What is the output of the following program?
#include <stdio.h>
int main() {
printf("%zu", sizeof('A'));
return 0;
}
A) 1
B) 2
C) 4
D) 8
Answer: C) 4
48 What is the output of the following program?
#include <stdio.h>
int main() {
char c = 'A';
printf("%zu", sizeof(c));
return 0;
}
A) 1
B) 2
C) 4
D) 8
Answer: A) 1
49 Which of the following data types is signed by default?
A) char
B) int
C) unsigned int
D) float
Answer: B) int
50 What will be the output of the code snippet below?
#include <stdio.h>
int main() {
printf("%d", sizeof(123.45F));
return 0;
}
A) 4
B) 8
C) 2
D) 16
Answer: A) 4
51 Which data type is used to store integers ranging from -32,768 to 32,767?
A) short
B) long
C) int
D) signed int
Answer: A) short
52 What is the result of the following program?
#include <stdio.h>
int main() {
int x = 10;
double y = 20.5;
printf("%d", x + y);
return 0;
}
A) 30.5
B) Garbage Value
C) Compilation Error
D) Runtime Error
#include <stdio.h>
int main() {
int x = 10;
double y = 20.5;
printf("%lf", x + y);
return 0;
}
A) 30.5
B) Garbage Value
C) Compilation Error
D) Runtime Error
Answer: A) 30.5
54 Which data type is used to store large integers in C?
A) long
B) double
C) int
D) float
Answer: A) long
55 What will be the output of the following program?
#include <stdio.h>
int main() {
printf("%zu", sizeof(10L));
return 0;
}
A) 2
B) 4
C) 8
D) 16
Answer: C) 8
56 What does the following program print?
#include <stdio.h>
int main() {
printf("%zu", sizeof(10.5));
return 0;
}
A) 4
B) 8
C) 2
D) 1
Answer: B) 8
57 Consider the following code:
#include <stdio.h>
int main() {
printf("%d", sizeof(int));
return 0;
}
What will be the output?
A) 2
B) 4
C) 8
D) Depends on the system
#include <stdio.h>
int main() {
printf("%d", sizeof(12345L));
return 0;
}
A) 2
B) 4
C) 8
D) 1
Answer: C) 8
60 What does the following program output?
#include <stdio.h>
int main() {
printf("%d", sizeof(char) + sizeof(int));
return 0;
}
A) 5
B) 6
C) 8
D) 9
Answer: A) 5
61 What is the output of the following code?
#include <stdio.h>
int main() {
printf("%d", sizeof('a' + 1.5));
return 0;
}
A) 4
B) 8
C) 2
D) 1
Answer: B) 8
62 What will be printed by the following code snippet?
#include <stdio.h>
int main() {
printf("%d", sizeof(short) + sizeof(short int));
return 0;
}
A) 2
B) 4
C) 3
D) 5
Answer: B) 4
63 What will the program output?
#include <stdio.h>
int main() {
printf("%d", sizeof(long long));
return 0;
}
A) 4
B) 8
C) 2
D) Compiler Error
Answer: B) 8
64 What is the output of the following code?
#include <stdio.h>
int main() {
printf("%d", sizeof(unsigned));
return 0;
}
A) 1
B) 2
C) 4
D) Compiler Error
Answer: C) 4
Variables
65 What happens if a variable is declared but not initialized in C?
#include <stdio.h>
int main() {
int x;
printf("%d", x);
return 0;
}
What will the output be?
A) 0
B) Garbage value
C) Compilation Error
D) Runtime Error
A) int while = 5;
B) int main = 0;
C) int Void = 10;
D) int Static = 20;
A) int a, b = 5; c;
B) int a = 5; b = 10;
C) int a = 5, b = 10;
D) a = 5, b = 10;
#include <stdio.h>
int main() {
int a = 5;
{
int a = 10;
printf("%d", a);
}
printf("%d", a);
return 0;
}
A) 510
B) 1010
C) 105
D) 51010
Answer: C) 105
71 Which of the following statements is true regarding variable names in C?
#include <stdio.h>
int main() {
int a = 5, b = 10;
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("%d %d\n", a, b);
return 0;
}
Options:
A) 10 5
B) 5 10
C) 0 0
D) Undefined behavior
Answer: A) 10 5
73 Which of the following is an invalid declaration in C?
Options:
A) int a[10];
B) float b = 5.5;
C) char c = "A";
D) double d = 10.5;
#include <stdio.h>
int main() {
int x = 5;
int y = (x++, ++x);
printf("%d\n", y);
return 0;
}
Options:
A) 5
B) 7
C) 11
D) Undefined behavior
Answer: B) 7
Modifiers (short, long, signed, unsigned)
75 What is the size of short int on a typical 32-bit machine?
A) 1 byte
B) 2 bytes
C) 4 bytes
D) Depends on the compiler
Answer: B) 2 bytes
76 What is the default type of an integer in C?
A) short int
B) int
C) long int
D) unsigned int
Answer: B) int
77 Which of the following can be used with a char data type?
A) signed
B) unsigned
C) both signed and unsigned
D) Neither signed nor unsigned
A) 0 to 65,535
B) 0 to 4,294,967,295
C) -2,147,483,648 to 2,147,483,647
D) -32,768 to 32,767
Answer: B) 0 to 4,294,967,295
79 When would you use long long int?
Answer: D) When you need a large integer range and long int is not enough.
80 What is the size of an unsigned int on a 64-bit machine?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) Depends on the compiler
Answer: B) 4 bytes
81 Can you have a signed unsigned int?
A) Yes
B) No
C) Only with specific compilers
D) Only in C++
Answer: B) No
82 What happens if you mix signed and unsigned in an expression?
A) Compiler error
B) Result is always signed
C) Result is always unsigned
D) Undefined behavior
A) signed
B) unsigned
C) long
D) short
Answer: B) unsigned
84 What is the main difference between signed int and int?
#include <stdio.h>
int main() {
printf("%ld", sizeof(unsigned int));
return 0;
}
A) 1
B) 2
C) 4
D) 8
Answer: C) 4
86 Predict the output of the code:
#include <stdio.h>
int main() {
printf("%d", sizeof(short) < sizeof(long));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
87 What will be printed?
#include <stdio.h>
int main() {
int x = -5;
unsigned int y = 10;
printf("%u", x + y);
return 0;
}
A) 5
B) 4294967296
C) 4294967291
D) Undefined
Answer: A) 5
88 Predict the output:
#include <stdio.h>
int main() {
short s = 32767;
s++;
printf("%d", s);
return 0;
}
A) 32767
B) -32768
C) Compiler Error
D) 32768
Answer: B) -32768
89 What will the code print?
#include <stdio.h>
int main() {
unsigned int a = 5;
int b = -10;
printf("%u", a + b);
return 0;
}
A) 4294967291
B) 4294967295
C) 5
D) 10
Answer: A) 4294967291
90 What is the output?
#include <stdio.h>
int main() {
printf("%d", -1L < 1UL);
return 0;
}
A) 0
B) 1
C) Compiler Error
D) Undefined
Answer: A) 0
Explanation: The condition is false because -1L, when compared with 1UL, is treated as two
unsigned values.
91 Predict the output:
#include <stdio.h>
int main() {
unsigned short int a = 65535;
a = a + 1;
printf("%u", a);
return 0;
}
A) 0
B) 65535
C) Compiler Error
D) 65536
Answer: A) 0
Explanation: Incrementing 65535 results in 65536 due to overflow.
92 What will be printed?
#include <stdio.h>
int main() {
printf("%d", sizeof(signed short int));
return 0;
}
A) 1
B) 2
C) 4
D) 8
Answer: B) 2
93 Predict the output:
#include <stdio.h>
int main() {
unsigned int x = 0;
printf("%d", --x);
return 0;
}
A) 0
B) -1
C) Compiler Error
D) Undefined
Answer: B) -1
94 What will the code print?
#include <stdio.h>
int main() {
signed char a = 128;
printf("%d", a);
return 0;
}
A) 128
B) -128
C) Compiler Error
D) 0
Answer: B) -128
95 Predict the output:
#include <stdio.h>
int main() {
printf("%ld", sizeof(long) - sizeof(short));
return 0;
}
A) 1
B) 2
C) 4
D) 6
Answer: D) 6
96 What will be printed?
#include <stdio.h>
int main() {
unsigned int x = 5;
printf("%d", x - 10);
return 0;
}
A) 4294967291
B) -5
C) 5
D) Compiler Error
Answer: B) -5
97 Predict the output:
#include <stdio.h>
int main() {
short int s = 0x7FFF;
printf("%d", s + 1 > s);
return 0;
}
A) 0
B) 1
C) Compiler Error
D) Undefined
Answer: B) 1
98 What will the code print?
#include <stdio.h>
int main() {
printf("%d", -5 > (unsigned int) -1);
return 0;
}
A) 0
B) 1
C) Compiler Error
D) Undefined
Answer: A) 0
99 Predict the output:
#include <stdio.h>
int main() {
printf("%u", sizeof(unsigned short int) - sizeof(signed short int));
return 0;
}
A) 0
B) 1
C) 2
D) 4
Answer: A) 0
100 What will be printed?
#include <stdio.h>
int main() {
printf("%d", sizeof(int) == sizeof(long) - 2);
return 0;
}
A) 0
B) 1
C) Compiler Error
D) Undefined
Answer: A) 0
101 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
printf("%u", -x);
return 0;
}
A) 5
B) -5
C) Compiler Error
D) 4294967291
Answer: D) 4294967291
102 What will the code print?
#include <stdio.h>
int main() {
printf("%d", (short int) 32768 + (short int) 1);
return 0;
}
A) 32769
B) -32767
C) 0
D) Compiler Error
Answer: B) -32767
103 Predict the output:
#include <stdio.h>
int main() {
unsigned char a = 255;
printf("%u", ++a);
return 0;
}
A) 255
B) 256
C) 0
D) Compiler Error
Answer: C) 0
104 What will be printed?
#include <stdio.h>
int main() {
printf("%d", sizeof(signed int) < sizeof(unsigned int));
return 0;
}
A) 0
B) 1
C) Compiler Error
D) Undefined
Answer: A) 0
Arithmetic operators
105 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int a = 5, b = 2, c;
c = a % b * 2 + a / b;
printf("%d", c);
return 0;
}
A) 3
B) 4
C) 5
D) 6
Answer: B) 4
106 Predict the output of the code:
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++ * ++x);
return 0;
}
A) 30
B) 35
C) 42
D) Undefined
Answer: B) 35
107 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 3;
printf("%d", x---y);
return 0;
}
A) 2
B) 5
C) 6
D) Error
Answer: A) 2
108 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", a++ + ++a);
return 0;
}
A) 11
B) 12
C) 13
D) Undefined
Answer: B) 12
109 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 7, y = 2;
printf("%d", x += x *= y + 3);
return 0;
}
A) 70
B) 77
C) 84
D) 91
Answer: A) 70
110 Predict the output of the following code:
#include <stdio.h>
int main() {
int a = 10, b = 20;
printf("%d", (a++) + (++b) * (a--));
return 0;
}
A) 230
B) 241
C) 252
D) 263
Answer: B) 241
111 What is the result of the following operation?
#include <stdio.h>
int main() {
int x = 15, y = 6;
printf("%d", x % y * x / y);
return 0;
}
A) 7
B) 18
C) 20
D) 25
Answer: C) 7
112 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3, c;
c = a-- - --b * 2;
printf("%d", c);
return 0;
}
A) 0
B) 1
C) 2
D) 3
Answer: B) 1
113 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8;
printf("%d", x-- + --x * 2);
return 0;
}
A) 16
B) 18
C) 20
D) 22
Answer: C) 20
114 Predict the output:
#include <stdio.h>
int main() {
int a = 3, b = 2, c = 5;
printf("%d", ++a * b-- + --c);
return 0;
}
A) 11
B) 12
C) 13
D) 14
Answer: B) 12
115 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int a = 4, b = 3, c = 2;
printf("%d", a++ * b-- + ++c);
return 0;
}
A) 15
B) 17
C) 18
D) 19
Answer: A) 15
116 Predict the output of the code:
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++ + x);
return 0;
}
A) 10
B) 11
C) 12
D) Undefined
Answer: B) 11
117 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10, y = 3;
printf("%d", x / y * x % y);
return 0;
}
A) 0
B) 2
C) 3
D) 4
Answer: A) 0
118 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a * (b + 1) - (b++));
return 0;
}
A) 12
B) 13
C) 14
D) 17
Answer: D) 17
119 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x * x++);
return 0;
}
A) 25
B) 30
C) 35
D) 40
Answer: B) 30
120 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 3;
printf("%d", a-- * b / a++);
return 0;
}
A) 3
B) 9
C) 12
D) 18
Answer: A) 3
121 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 8, y = 2;
printf("%d", x -= x * y);
return 0;
}
A) 3
B) 8
C) 12
D) 16
Answer: A) 3
122 Predict the output:
#include <stdio.h>
int main() {
int a = 4, b = 2, c = 3;
printf("%d", a * (b + c--) + b);
return 0;
}
A) 12
B) 22
C) 16
D) 18
Answer: B) 22
123 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6;
printf("%d", x-- * x++);
return 0;
}
A) 30
B) 35
C) 40
D) 45
Answer: A) 30
124 Predict the output:
#include <stdio.h>
int main() {
int a = 4, b = 3, c = 2;
printf("%d", a-- * b++ / --c);
return 0;
}
A) 6
B) 8
C) 10
D) 12
Answer: D) 12
125 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 2;
printf("%d", x * ++y - y++);
return 0;
}
A) 12
B) 14
C) 15
D) 16
Answer: A) 12
126 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 4, c = 3;
printf("%d", a++ + b-- - c);
return 0;
}
A) 6
B) 7
C) 8
D) 9
Answer: A) 6
127 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 3;
printf("%d", x * x++);
return 0;
}
A) 9
B) 12
C) 15
D) 18
Answer: B) 12
128 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 3;
printf("%d", a-- / ++b * a++);
return 0;
}
A) 6
B) 10
C) 11
D) 12
Answer: A) 6
129 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6, y = 3;
printf("%d", x -= --y * 2);
return 0;
}
A) 0
B) 2
C) 6
D) 9
Answer: B) 2
130 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2, c = 3;
printf("%d", a++ * b-- / --c);
return 0;
}
A) 6
B) 12
C) 15
D) 18
Answer: A) 6
131 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8, y = 2;
printf("%d", x -= x % ++y);
return 0;
}
A) 4
B) 5
C) 6
D) 7
Answer: C) 6
132 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3, c = 4;
printf("%d", a-- * b++ + c--);
return 0;
}
A) 19
B) 21
C) 22
D) 23
Answer: A) 19
133 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7;
printf("%d", x++ * x--);
return 0;
}
A) 48
B) 49
C) 50
D) 56
Answer: D) 56
134 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2, c = 3;
printf("%d", a++ * --b / c--);
return 0;
}
A) 2
B) 6
C) 8
D) 10
Answer: A) 2
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d", x > y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
136 Predict the output:
#include <stdio.h>
int main() {
int a = 10, b = 20, c = 30;
printf("%d", a < b > c);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
137 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x >= 5);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
138 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 5;
printf("%d", a == b);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
139 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d", x != y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
140 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 3;
printf("%d", a <= b);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
141 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8, y = 2;
printf("%d", x > y && x < y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
142 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", !(a > b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
143 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 5;
printf("%d", x >= y || x < y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
144 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2, c = 3;
printf("%d", (a > b) && (b > c));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
145 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7;
printf("%d", x != 7 || x == 7);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
146 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 5, c = 6;
printf("%d", (a == b) && (b != c));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
147 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10, y = 5;
printf("%d", x > y && x < y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
148 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 4;
printf("%d", !(a == b) && (a < b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
149 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8, y = 2;
printf("%d", x == y || x != y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
150 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 7, c = 6;
printf("%d", (a != b) && (b == c));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
151 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", !(x >= 5) || !(x < 10));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
152 Predict the output:
#include <stdio.h>
int main() {
int a = 4, b = 2;
printf("%d", !(a == b) && (a > b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
153 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7;
printf("%d", x == 7 && x == 6);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
154 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 7, c = 6;
printf("%d", (a < b) || (b > c));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
155 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6, y = 3;
printf("%d", x != y && x == y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
156 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 5, c = 5;
printf("%d", (a == b) && (b == c));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
157 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7, y = 5;
printf("%d", x <= y || x >= y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
158 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 4;
printf("%d", !(a == b) && (a != b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
159 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", !(x < 5) && !(x > 5));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
Logical operators
160 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d", x && y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
161 Predict the output:
#include <stdio.h>
int main() {
int a = 0, b = 20, c = 30;
printf("%d", a || b && c);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
162 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", !x);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
163 Predict the output:
#include <stdio.h>
int main() {
int a = 10, b = 20;
printf("%d", !(a > b) || (a < b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
164 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d", x && !y);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
165 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 3;
printf("%d", !(a == b) && (a > b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
166 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 0;
printf("%d", x || !x);
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
167 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", !(a > b) && (a != b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
168 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6;
printf("%d", x && (x = 5));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
169 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 7;
printf("%d", (a < b) && (b > a));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
170 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 0;
printf("%d", x || (y = 10));
return 0;
}
A) 0
B) 1
C) 10
D) Undefined
Answer: B) 1
171 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 3;
printf("%d", !(a == b) || (a != b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
172 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x && (x = 0));
return 0;
}
A) 0
B) 1
C) 5
D) Undefined
Answer: A) 0
173 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 5;
printf("%d", !(a == b) && (a >= b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
174 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7, y = 0;
printf("%d", x || y && (y = 5));
return 0;
}
A) 0
B) 1
C) 5
D) Undefined
Answer: B) 1
175 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2;
printf("%d", !(a > b) || (a < b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
176 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 0, y = 5;
printf("%d", x && (y = 7));
return 0;
}
A) 0
B) 1
C) 7
D) Undefined
Answer: A) 0
177 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", (a > b) || !(a == b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
178 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 7;
printf("%d", x && (y = 0));
return 0;
}
A) 0
B) 1
C) 0 (but y changes)
D) Undefined
Answer: A) 0
179 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2;
printf("%d", !(a == b) && (a > b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
180 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x || (x = 10));
return 0;
}
A) 0
B) 1
C) 5
D) Undefined
Answer: B) 1
181 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 7;
printf("%d", !(a < b) || (a > b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: A) 0
182 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 0, y = 5;
printf("%d", x || (y = 7));
return 0;
}
A) 0
B) 1
C) 7
D) Undefined
Answer: A) 0
183 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 2;
printf("%d", !(a > b) || (a != b));
return 0;
}
A) 0
B) 1
C) Error
D) Undefined
Answer: B) 1
184 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 0;
printf("%d", x && (x = 10));
return 0;
}
A) 0
B) 1
C) 10
D) Undefined
Answer: B) 1
Bitwise operators
185 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5, y = 3;
printf("%d", x & y);
return 0;
}
A) 1
B) 3
C) 5
D) 0
Answer: A) 1
186 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 3;
printf("%d", a | b);
return 0;
}
A) 2
B) 3
C) 7
D) 21
Answer: C) 7
187 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", ~x);
return 0;
}
A) 4
B) 5
C) -5
D) -6
Answer: C) -6
188 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a ^ b);
return 0;
}
A) 6
B) 7
C) 8
D) 15
Answer: A) 6
189 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6;
printf("%d", x << 1);
return 0;
}
A) 12
B) 3
C) 24
D) 48
Answer: A) 12
190 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", a >> 1);
return 0;
}
A) 2
B) 2.5
C) 1
D) 3
Answer: A) 2
191 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 9;
printf("%d", x & ~y);
return 0;
}
A) 4
B) 5
C) 9
D) -14
Answer: A) 4
192 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 3;
printf("%d", a | ~b);
return 0;
}
A) -1
B) -7
C) 0
D) 1
Answer: A) -1
193 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x ^ x);
return 0;
}
A) 0
B) 5
C) 1
D) -1
Answer: A) 0
194 Predict the output:
#include <stdio.h>
int main() {
int a = 6;
printf("%d", a << 2);
return 0;
}
A) 24
B) 12
C) 48
D) 6
Answer: A) 24
195 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 3;
printf("%d", x | (1 << y));
return 0;
}
A) 13
B) 5
C) 7
D) 9
Answer: A) 13
196 Predict the output:
#include <stdio.h>
int main() {
int a = 7;
printf("%d", a >> 2);
return 0;
}
A) 1
B) 2
C) 3
D) 4
Answer: A) 1
197 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8, y = 2;
printf("%d", x & (1 << y));
return 0;
}
A) 0
B) 2
C) 8
D) 16
Answer: A) 0
198 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", ~a);
return 0;
}
A) -5
B) -6
C) 4
D) 5
Answer: B) -6
199 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7, y = 3;
printf("%d", x ^ (1 << y));
return 0;
}
A) 15
B) 7
C) 3
D) 5
Answer: A) 15
200 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a | (1 << b));
return 0;
}
A) 7
B) 5
C) 13
D) 8
Answer: C) 13
201 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6;
printf("%d", x << 3);
return 0;
}
A) 24
B) 12
C) 48
D) 6
Answer: C) 48
202 Predict the output:
#include <stdio.h>
int main() {
int a = 7;
printf("%d", a >> 3);
return 0;
}
A) 0
B) 1
C) 2
D) 7
Answer: A) 0
203 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 2;
printf("%d", x & (1 << y));
return 0;
}
A) 0
B) 2
C) 5
D) 4
Answer: D) 4
204 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 2;
printf("%d", a ^ (1 << b));
return 0;
}
A) 1
B) 5
C) 3
D) 4
Answer: A) 1
205 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 8, y = 3;
printf("%d", x | (1 << y));
return 0;
}
A) 8
B) 11
C) 12
D) 10
Answer: A) 8
206 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 2;
printf("%d", a & (1 << b));
return 0;
}
A) 0
B) 2
C) 4
D) 7
Answer: C) 4
207 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 6, y = 3;
printf("%d", x ^ (1 << y));
return 0;
}
A) 0
B) 3
C) 6
D) 14
Answer: D) 14
208 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 2;
printf("%d", a | (1 << b));
return 0;
}
A) 7
B) 5
C) 3
D) 4
Answer: B) 5
209 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 7, y = 2;
printf("%d", x & (1 << y));
return 0;
}
A) 0
B) 2
C) 4
D) 7
Answer: C) 4
Increment and decrement operators
210 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++);
return 0;
}
A) 5
B) 6
C) Compilation Error
D) Undefined
Answer: A) 5
211 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", ++a);
return 0;
}
A) 5
B) 6
C) 7
D) Compilation Error
Answer: B) 6
212 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x--);
return 0;
}
A) 5
B) 6
C) Compilation Error
D) Undefined
Answer: A) 5
213 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", --a);
return 0;
}
A) 5
B) 4
C) 6
D) Compilation Error
Answer: B) 4
214 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 5;
printf("%d %d", x++, ++y);
return 0;
}
A) 5 6
B) 6 6
C) 5 5
D) 6 5
Answer: A) 5 6
215 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b;
b = a++ + ++a;
printf("%d", b);
return 0;
}
A) 11
B) 12
C) 13
D) Compilation Error
Answer: B) 12
216 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", x--, x++);
return 0;
}
A) 5 5
B) 4 6
C) 6 5
D) 4 5
Answer: C) 6 5
217 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", ++a, a--);
return 0;
}
A) 6 5
B) 5 6
C) 6 6
D) 5 5
Answer: D) 5 5
218 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", ++x, --x);
return 0;
}
A) 6 5
B) 5 6
C) 6 6
D) 5 5
Answer: A) 6 5
Explanation: The value of x is incremented first and then decremented, but the effects are
observed in separate expressions.
219 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", a++ + ++a, --a);
return 0;
}
A) 12 6
B) 13 5
C) 11 5
D) Compilation Error
Answer: A) 12 6
220 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", x++ + ++x, x-- - --x);
return 0;
}
A) 12 0
B) 8 2
C) 10 1
D) Compilation Error
Answer: B) 8 2
221 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", ++a + a++, a);
return 0;
}
A) 12 7
B) 11 6
C) 13 7
D) Compilation Error
Answer: C) 13 7
222 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", x-- - --x, x++ + ++x);
return 0;
}
A) 2 12
B) 1 11
C) -1 11
D) Compilation Error
Answer: A) 2 12
223 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", a++ + ++a, --a - a--);
return 0;
}
A) 12 -2
B) 8 -1
C) 11 -2
D) Compilation Error
Answer: B) 8 -1
224 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", x++ - ++x, x-- + ++x);
return 0;
}
A) 0 12
B) 1 11
C) -2 10
D) Compilation Error
Answer: C) -2 10
225 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", a++ + ++a, --a + a--);
return 0;
}
A) 12 8
B) 8 7
C) 11 8
D) Compilation Error
Answer: B) 8 7
226 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", x-- + --x, x++ - ++x);
return 0;
}
A) 8 0
B) 7 1
C) 12 -2
D) Compilation Error
Answer: C) 12 -2
227 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", a++ - --a, ++a + a--);
return 0;
}
A) 0 11
B) 1 11
C) -1 11
D) Compilation Error
Answer: A) 0 11
228 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d", ++x + x++, --x - x--);
return 0;
}
A) 9 -1
B) 11 0
C) 12 1
D) Compilation Error
Answer: A) 9 -1
229 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d %d", a-- + --a, ++a - a++);
return 0;
}
A) 12 1
B) 7 1
C) 7 0
D) Compilation Error
Answer: A) 12 1
230 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
printf("%d", a++ + ++a);
return 0;
}
A) 12
B) 7
C) 7
D) Compilation Error
Answer: A) 12
Decision-making statements (if, if-else, nested if-else)
231 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5;
if (x = 0)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined Behavior
Answer: B) False
232 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 7;
if (a > b)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No Output
D) Compilation Error
Answer: B) World
233 What will be printed by the code below?
#include <stdio.h>
int main() {
int x = 10;
if (x > 5)
if (x < 15)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
234 Predict the output:
#include <stdio.h>
int main() {
int x = 10;
if (x > 5)
if (x < 15)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
235 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5 && y > 3)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
236 Predict the output:
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5 || y > 10)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
237 Predict the output:
#include <stdio.h>
int main() {
int a = 10, b = 20;
if (a < b) {
printf("C");
if (b > a)
printf("D");
}
return 0;
}
A) CD
B) C
C) D
D) Compilation Error
Answer: A) CD
238 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (x > 4)
printf("Hello");
printf("World");
return 0;
}
A) HelloWorld
B) Hello
World
C) Compilation Error
D) Undefined Behavior
Answer: A) HelloWorld
239 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 4 || y < 5)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
240 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 10;
if (a == 5)
if (b == 10)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
241 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3)
if (y < 12)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
242 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
if (a == 5)
printf("A");
else if (a == 6)
printf("B");
else if (a == 7)
printf("C");
else
printf("D");
return 0;
}
A) A
B) B
C) C
D) D
Answer: A) A
243 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 && y < 12)
if (x < 6)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
244 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 10;
if (a == 5)
if (b == 10)
printf("A");
else
printf("B");
else
printf("C");
return 0;
}
A) A
B) B
C) C
D) Compilation Error
Answer: A) A
245 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 && y < 5)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: B) B
246 Predict the output:
#include <stdio.h>
int main() {
int a = 5;
if (a == 4)
printf("A");
else if (a == 5)
printf("B");
else
printf("C");
return 0;
}
A) A
B) B
C) C
D) Compilation Error
Answer: B) B
247 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x < 3 || y > 12)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: B) B
248 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 10;
if (a == 5)
if (b != 10)
printf("A");
else
printf("B");
else
printf("C");
return 0;
}
A) A
B) B
C) C
D) Compilation Error
Answer: B) B
249 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (x < 3)
printf("A");
else if (x < 6)
printf("B");
else
printf("C");
return 0;
}
A) A
B) B
C) C
D) Compilation Error
Answer: B) B
250 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 10;
if (a != 4)
if (b == 10)
printf("A");
else
printf("B");
else
printf("C");
return 0;
}
A) A
B) B
C) C
D) Compilation Error
Answer: A) A
251 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 && y < 12)
printf("A");
else
printf("B");
return 0;
}
A) A
B) B
C) Compilation Error
D) No Output
Answer: A) A
252 Predict the output:
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5)
if (y > 5)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: B) World
253 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10;
if (x == 10)
printf("X is ten");
else if (x == 9)
printf("X is nine");
else
printf("X is neither ten nor nine");
return 0;
}
A) X is ten
B) X is nine
C) X is neither ten nor nine
D) Compilation Error
Answer: A) X is ten
254 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
if (x = 0)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: B) False
255 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (x == 5) {
printf("First if block\n");
if (x > 3)
printf("Nested if block");
}
return 0;
}
A) First if block
B) Nested if block
C) Both First if block and Nested if block
D) No output
#include <stdio.h>
int main() {
int x = 10, y = 20;
if (x > y)
printf("x is greater");
else if (y > x)
printf("y is greater");
else
printf("Both are equal");
return 0;
}
A) x is greater
B) y is greater
C) Both are equal
D) Compilation Error
Answer: B) y is greater
257 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (x > 3)
if (x < 10)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: A) Hello
258 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
if (x > 3)
if (x < 10)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: A) Hello
259 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10;
if (x != 10) {
printf("X is not ten");
}
else if (x > 5) {
printf("X is greater than five");
}
return 0;
}
A) X is not ten
B) X is greater than five
C) No output
D) Compilation Error
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5 && y < 10)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: A) True
261 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (x > 3) {
if (x < 7)
printf("Hello");
else
printf("World");
}
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: A) Hello
262 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
if (x > 3)
if (x < 7)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: A) Hello
263 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10;
if (x != 5)
printf("Not five\n");
if (x > 5)
printf("Greater than five");
return 0;
}
A) Not five
Greater than five
B) Not five
C) Greater than five
D) Compilation Error
#include <stdio.h>
int main() {
int x = 5;
if (x > 3)
if (x < 7)
printf("Hello\n");
else
printf("World");
return 0;
}
A) Hello
B) World
C) Hello followed by World
D) No output
Answer: A) Hello
265 Predict the output:
#include <stdio.h>
int main() {
int x = 10, y = 20;
if (x == 10 && y == 20)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: A) True
266 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 || y < 7)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: A) True
267 Predict the output:
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 && y < 7)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: B) False
268 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
if (x > 3 && x < 7)
if (x == 6)
printf("Hello");
else
printf("World");
return 0;
}
A) Hello
B) World
C) No output
D) Compilation Error
Answer: B) World
269 Predict the output:
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3 || y < 7)
printf("True");
else
printf("False");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: A) True
270 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5;
if (!(x > 3))
printf("False");
else
printf("True");
return 0;
}
A) True
B) False
C) Compilation Error
D) Undefined
Answer: A) True
Decision-making statements (switch-case)
271 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 3;
switch (x) {
case 1:
printf("One ");
break;
case 2:
printf("Two ");
break;
default:
printf("Default ");
}
return 0;
}
A) One
B) Two
C) Default
D) Compilation Error
Answer: C) Default
272 Predict the output:
#include <stdio.h>
int main() {
int x = 2;
switch (x) {
case 1:
printf("Case 1 ");
break;
case 2:
printf("Case 2 ");
break;
case 3:
printf("Case 3 ");
}
return 0;
}
A) Case 1
B) Case 2
C) Case 3
D) Compilation Error
Answer: B) Case 2
273 Predict the output:
#include <stdio.h>
int main() {
int x = 2;
switch (x) {
case 1:
printf("One ");
break;
case 2:
printf("Two ");
case 3:
printf("Three ");
break;
default:
printf("Default ");
}
return 0;
}
A) Two
B) Two Three
C) Two Three Default
D) Compilation Error
#include <stdio.h>
int main() {
int x = 1;
switch (x) {
case 1:
printf("One ");
case 2:
printf("Two ");
case 3:
printf("Three ");
default:
printf("Default ");
}
return 0;
}
A) One
B) One Two Three Default
C) One Two Three Default Default
D) Compilation Error
#include <stdio.h>
int main() {
int x = 0;
switch (x) {
default:
printf("Default ");
case 1:
printf("One ");
break;
case 2:
printf("Two ");
}
return 0;
}
A) Default One
B) One
C) Default One Two
D) Compilation Error
#include <stdio.h>
int main() {
int x = 0;
switch (x) {
case 0:
printf("Zero ");
case 1:
printf("One ");
break;
case 2:
printf("Two ");
}
return 0;
}
A) Zero One
B) Zero One Two
C) Zero
D) Compilation Error
#include <stdio.h>
int main() {
int x = 3;
switch (x) {
case 1:
printf("One ");
break;
case 2:
printf("Two ");
break;
default:
printf("Default ");
case 3:
printf("Three ");
}
return 0;
}
A) One
B) Two
C) Default Three
D) Compilation Error
int main() {
int x = 65;
switch (x) {
case 'A':
printf("A ");
break;
case 65:
printf("65 ");
break;
default:
printf("Default ");
case 3:
printf("Three ");
}
return 0;
}
A) A
B) 65
C) Default Three
D) Compilation Error
Answer: A) A
280 What will be printed by the following code?
#include <stdio.h>
int main() {
float x = 65;
switch (x) {
case 'A':
printf("A ");
break;
default:
printf("Default ");
case 3:
printf("Three ");
}
return 0;
}
A) A
B) 65
C) Default Three
D) Compilation Error
#include <stdio.h>
int main() {
for (int i = 0; i < 5; ++i)
printf("%d ", i);
return 0;
}
A) 0 1 2 3 4
B) 1 2 3 4 5
C) 0 1 2 3
D) 1 2 3 4
Answer: A) 0 1 2 3 4
282 Predict the output:
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 5; i += 2)
printf("%d ", i);
return 0;
}
A) 0 1 2 3 4
B) 0 2 4
C) 2 4
D) 0 1 3 4
Answer: B) 0 2 4
283 What will be printed by the code below?
#include <stdio.h>
int main() {
for (int i = 5; i > 0; i--)
printf("%d ", i);
return 0;
}
A) 5 4 3 2 1
B) 4 3 2 1 0
C) 5 4 3 2
D) 4 3 2 1
Answer: A) 5 4 3 2 1
284 Predict the output:
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; ++i)
printf("%d ", i * i);
return 0;
}
A) 1 4 9 16 25
B) 0 1 4 9 16
C) 1 2 3 4 5
D) 2 4 6 8 10
Answer: A) 1 4 9 16 25
285 What will be printed by the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++)
printf("%d ", i++);
return 0;
}
A) 0 2 4
B) 0 1 2 3 4
C) 0 1 2 3
D) 1 3
Answer: A) 0 2 4
286 Predict the output:
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++)
printf("%d ", ++i);
return 0;
}
A) 1 2 3 4 5
B) 0 1 2 3 4
C) 1 3 5
D) 0 2 4
Answer: C) 1 3 5
287 What will be printed by the following code?
#include <stdio.h>
int main() {
for (int i = 5; i>=0; i -= 2)
printf("%d ", i);
return 0;
}
A) 5 3 1
B) 4 2 0
C) 5 2
D) 5 3
Answer: A) 5 3 1
288 Predict the output:
#include <stdio.h>
int main() {
for (int i = 0; i < 5; ++i)
printf("%d ", i--);
return 0;
}
A) Infinite loop
B) 0 0 0 0 0
C) 0 1 2 3 4
D) 0 1 2 3
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 0; i < 5; sum += i++);
printf("%d", sum);
return 0;
}
A) 15
B) 10
C) 5
D) 6
Answer: B) 10
290 What will be printed by the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i = i + 3)
printf("%d ", i);
return 0;
}
A) 0 3
B) 0
C) 0 1 2 3 4
D) 0 3 6
Answer: A) 0 3
291 What will be printed by the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i *= 2)
printf("%d ", i);
return 0;
}
A) 1 2 3 4 5
B) 1 2 4
C) 1 2 4 8
D) 1 3
Answer: C) 1 2 4
292 Predict the output:
#include <stdio.h>
int main() {
for (int i = 0; i <= 5; i += 2)
printf("%d ", i);
return 0;
}
A) 0 1 2 3 4 5
B) 0 2 4
C) 0 2 4 6 8
D) 1 3 5
Answer: C) 0 2 4
293 What will be printed by the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; ++i)
printf("%d ", ++i);
return 0;
}
A) 2 4 6
B) 1 3 5
C) 3 5
D) 2 3 4
Answer: A) 2 4 6
294 Predict the output:
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++)
printf("%d ", i);
printf("%d", i);
return 0;
}
A) 0 1 2 3 4 5
B) 0 1 2 3 4 4
C) 0 1 2 3 4 6
D) Compilation Error
#include <stdio.h>
int main() {
int i = 0;
for (; i < 5; i++)
printf("%d ", i);
printf("\nOutside Loop: %d", i);
return 0;
}
A) 0 1 2 3 4 Outside Loop: 5
B) 0 1 2 3 4 Outside Loop: 4
C) 0 1 2 3 4 Outside Loop: 6
D) 0 1 2 3 4
Answer: A) 0 1 2 3 4 Outside Loop: 5
Looping statements (while, do-while)
296 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i = 5;
while (i--) {
printf("%d ", i);
}
return 0;
}
A) 4 3 2 1 0
B) 5 4 3 2 1
C) 4 3 2 1
D) 5 4 3 2
Answer: A) 4 3 2 1 0
297 Predict the output:
#include <stdio.h>
int main() {
int x = 1;
do {
printf("%d ", x++);
} while (++x <= 5);
return 0;
}
A) 1 3 5
B) 1 2 3 4 5
C) 2 3 4
D) 1
Answer: A) 1 3 5
298 What will be printed by the code below?
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
printf("%d ", ++i);
}
return 0;
}
A) 1 2 3 4 5
B) 0 1 2 3 4
C) 0 1 2 3 4 5
D) 1 2 3 4
Answer: A) 1 2 3 4 5
299 Predict the output:
#include <stdio.h>
int main() {
int x = 10;
do {
printf("%d ", x);
} while (--x > 5);
return 0;
}
A) 10 9 8 7 6
B) 10 9 8 7
C) 9 8 7 6
D) 10 9 8
Answer: A) 10 9 8 7 6
300 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 5;
while (i) {
printf("%d ", i--);
}
return 0;
}
A) 5 4 3 2 1
B) 4 3 2 1 0
C) 5 4 3 2
D) 4 3 2 1
Answer: A) 5 4 3 2 1
301 Predict the output:
#include <stdio.h>
int main() {
int x = 1;
do {
printf("%d ", x);
x *= 2;
} while (x < 10);
return 0;
}
A) 1 2 4 8
B) 1 2 4 8 16
C) 1 2 4
D) 1 2 4 16
Answer: A) 1 2 4 8
302 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 2;
while (++i < 5) {
printf("%d ", i);
}
return 0;
}
A) 3 4
B) 2 3 4
C) 3 4 5
D) 2 3
Answer: A) 3 4
303 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
do {
printf("%d ", x++);
} while (x < 8);
return 0;
}
A) 5 6 7 8
B) 5 6 7
C) 6 7 8
D) 5 6
Answer: B) 5 6 7
304 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 3;
while (i--) {
printf("%d ", i);
}
return 0;
}
A) 2 1 0
B) 3 2 1
C) 3 2
D) 2 1
Answer: A) 2 1 0
305 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i = 5;
while (i--) {
printf("%d ", i);
}
return 0;
}
A) 4 3 2 1 0
B) 5 4 3 2 1
C) 4 3 2 1
D) 5 4 3 2
Answer: A) 4 3 2 1 0
306 Predict the output:
#include <stdio.h>
int main() {
int x = 1;
do {
printf("%d ", x++);
} while (++x <= 5);
return 0;
}
A) 1 3 5
B) 1 2 3 4 5
C) 2 3 4
D) 1
Answer: A) 1 3 5
307 What will be printed by the code below?
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
printf("%d ", ++i);
}
return 0;
}
A) 1 2 3 4 5
B) 0 1 2 3 4
C) 0 1 2 3 4 5
D) 1 2 3 4
Answer: A) 1 2 3 4 5
308 Predict the output:
#include <stdio.h>
int main() {
int x = 10;
do {
printf("%d ", x);
} while (--x > 5);
return 0;
}
A) 10 9 8 7 6
B) 10 9 8 7
C) 9 8 7 6
D) 10 9 8
Answer: A) 10 9 8 7 6
309 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 5;
while (i) {
printf("%d ", i--);
}
return 0;
}
A) 5 4 3 2 1
B) 4 3 2 1 0
C) 5 4 3 2
D) 4 3 2 1
Answer: A) 5 4 3 2 1
310 Predict the output:
#include <stdio.h>
int main() {
int x = 1;
do {
printf("%d ", x);
x *= 2;
} while (x < 10);
return 0;
}
A) 1 2 4 8
B) 1 2 4 8 16
C) 1 2 4
D) 1 2 4 16
Answer: A) 1 2 4 8
311 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 2;
while (++i < 5) {
printf("%d ", i);
}
return 0;
}
A) 3 4
B) 2 3 4
C) 3 4 5
D) 2 3
Answer: A) 3 4
312 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
do {
printf("%d ", x++);
} while (x < 8);
return 0;
}
A) 5 6 7 8
B) 5 6 7
C) 6 7 8
D) 5 6
Answer: B) 5 6 7
313 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 3;
while (i--) {
printf("%d ", i);
}
return 0;
}
A) 2 1 0
B) 3 2 1
C) 3 2
D) 2 1
Answer: A) 2 1 0
314 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
do {
printf("%d ", ++x);
} while (x < 10);
return 0;
}
A) 6 7 8 9
B) 6 7 8 9 10
C) 5 6 7 8 9
D) 7 8 9
Answer: B) 6 7 8 9 10
315 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 0;
while (i++ < 2) {
printf("%d ", ++i);
}
return 0;
}
A) 2
B) 2 3
C) 1 3
D) 2 3 4
Answer: A) 2
316 Predict the output:
#include <stdio.h>
int main() {
int x = 1;
do {
printf("%d ", x++);
} while (++x < 5);
return 0;
}
A) 1 2 3
B) 1 2 3 4
C) 2 3
D) 1 3
Answer: D) 1 3
317 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 5;
while (i--) {
printf("%d ", i);
if (i == 2)
break;
}
return 0;
}
A) 4 3 2
B) 4 3 2 1 0
C) 4 3 2 1
D) 5 4 3 2 1
Answer: A) 4 3 2
318 Predict the output:
#include <stdio.h>
int main() {
int x = 10;
do {
printf("%d ", x--);
} while (--x > 5);
return 0;
}
A) 10 9 8 7 6
B) 10 8 6
C) 10 9 8
D) 9 8 7
Answer: B) 10 8 6
319 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 1;
while (i < 5) {
printf("%d ", i);
if (++i == 3)
continue;
}
return 0;
}
A) 1 2 3 4
B) 1 2 4
C) 1 3 4
D) 1 2
Answer: A) 1 2 3 4
320 Predict the output:
#include <stdio.h>
int main() {
int x = 5;
do {
printf("%d ", --x);
} while (x > 0);
return 0;
}
A) 4 3 2 1 0
B) 5 4 3 2 1
C) 4 3 2 1
D) 5 4 3 2
Answer: A) 4 3 2 1 0
321 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 3;
while (i--) {
printf("%d ", i);
if (i == 1)
continue;
}
return 0;
}
A) 2 1 0
B) 2 1
C) 1 0
D) 2 0
Answer: A) 2 1 0
322 What will be printed by the code below?
#include <stdio.h>
int main() {
int i = 1;
while (i++ < 5) {
printf("%d ", i);
}
return 0;
}
A) 2 3 4 5
B) 1 2 3 4
C) 2 3 4
D) 1 2 3 4 5
Answer: A) 2 3 4 5
323 Predict the output:
#include <stdio.h>
int main() {
int i = 5;
do {
printf("%d ", i);
} while (--i > 0);
return 0;
}
A) 5 4 3 2 1
B) 4 3 2 1
C) 5 4 3 2
D) 6 5 4 3
Answer: A) 5 4 3 2 1
324 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 10;
while (i-- > 5) {
printf("%d ", i);
}
return 0;
}
A) 9 8 7 6 5
B) 10 9 8 7 6
C) 9 8 7 6
D) 10 9 8 7
Answer: A) 9 8 7 6 5
325 Predict the output:
#include <stdio.h>
int main() {
int i = 1;
do {
printf("%d ", i * 2);
} while (i++ < 4);
return 0;
}
A) 2 4 6 8
B) 2 4 6
C) 2 4 6 8 10
D) 1 2 3 4
Answer: A) 2 4 6 8
326 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 0;
while (++i < 3) {
printf("%d ", ++i);
}
return 0;
}
A) 2
B) 1 2 3
C) 2 4
D) 1 3
Answer: A) 2
327 Predict the output:
#include <stdio.h>
int main() {
int i = 5;
do {
printf("%d ", i--);
} while (i > 2);
return 0;
}
A) 5 4 3
B) 4 3 2
C) 5 4 3 2
D) 6 5 4 3
Answer: A) 5 4 3
328 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 2;
while (--i) {
printf("%d ", i * 2);
}
return 0;
}
A) 2
B) 2 4
C) 4 2
D) 4
Answer: B) 2 4
329 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 5;
do {
printf("%d ", i++);
} while (i < 8);
return 0;
}
A) 5 6 7
B) 5 6 7 8
C) 6 7 8
D) 5 7 9
Answer: A) 5 6 7
330 Predict the output:
#include <stdio.h>
int main() {
int i = 1;
while (i++ <= 3) {
printf("%d ", i);
}
return 0;
}
A) 2 3 4
B) 1 2 3
C) 2 3
D) 1 2 3 4
Answer: A) 2 3 4
331 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 3;
do {
printf("%d ", i--);
} while (--i > 0);
return 0;
}
A) 3 1
B) 3 2 1
C) 3 2
D) 2 1
Answer: A) 3 1
332 Predict the output:
#include <stdio.h>
int main() {
int i = 5;
do {
printf("%d ", i--);
} while (i > 1);
return 0;
}
A) 5 4 3 2
B) 4 3 2 1
C) 5 4 3
D) 5 4
Answer: A) 5 4 3 2
333 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 0;
while (++i <= 2) {
printf("%d ", i);
i++;
}
return 0;
}
A) 1 2
B) 1 2 3
C) 1 3
D) 1
Answer: D) 1
334 Predict the output:
#include <stdio.h>
int main() {
int i = 2;
while (--i) {
printf("%d ", i);
}
return 0;
}
A) 1
B) 1 0
C) 1 0 1
D) 2 1
Answer: A) 1
335 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 4;
while (i--) {
printf("%d ", i);
}
return 0;
}
A) 3 2 1 0
B) 4 3 2 1
C) 3 2 1
D) 4 3 2
Answer : A) 3 2 1 0
Break and continue statements
336 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i == 3)
break;
printf("%d ", i);
}
return 0;
}
A) 1 2
B) 1 2 3
C) 1 2 4 5
D) 1 2 3 4 5
Answer: A) 1 2
337 Predict the output:
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 3 5
B) 2 4
C) 1 2 3 4 5
D) None of the above
Answer: A) 1 3 5
338 What will be printed by the code below?
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
if (i == 3)
break;
printf("%d ", i);
i++;
}
return 0;
}
A) 0 1 2
B) 0 1 2 3
C) 0 1 2 4
D) 0 1 2 3 4
Answer: A) 0 1 2
339 Predict the output:
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
i++;
if (i == 3)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 2 4 5
B) 2 4 5
C) 1 2 3 4 5
D) None of the above
Answer: A) 1 2 4 5
340 Predict the output:
#include <stdio.h>
int main() {
int i = 0;
do {
i++;
if (i == 3)
break;
printf("%d ", i);
} while (i < 5);
return 0;
}
A) 1 2
B) 1 2 3
C) 1 2 4
D) 2 3
Answer: A) 1 2
341 What will be printed by the code below?
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 3 5
B) 2 4
C) 1 2 3 4 5
D) 1 2 4 5
Answer: A) 1 3 5
342 Predict the output:
#include <stdio.h>
int main() {
int i = 0;
do {
i++;
if (i == 3)
continue;
printf("%d ", i);
} while (i < 5);
return 0;
}
A) 1 2 4 5
B) 2 4 5
C) 1 2 3 4 5
D) None of the above
Answer: A) 1 2 4 5
343 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
i++;
if (i % 2 == 0)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 3 5
B) 2 4
C) 1 2 3 4 5
D) 1 2 4 5
Answer: A) 1 3 5
344 Predict the output:
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i == 3)
break;
printf("%d ", i);
}
return 0;
}
A) 1 2
B) 1 2 3
C) 1 2 4 5
D) 1 2 3 4 5
Answer: A) 1 2
345 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i;
for (i = 1; i <= 5; i++) {
if (i == 3)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 2 3 4 5
B) 1 2 4 5
C) 1 2 3 4
D) 2 4 5
Answer: B) 1 2 4 5
346 Predict the output:
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
i++;
if (i == 3)
break;
printf("%d ", i);
}
return 0;
}
A) 1 2
B) 1 2 3
C) 1 2 4 5
D) 1 2 3 4 5
Answer: A) 1 2
347 What will be printed by the following code?
#include <stdio.h>
int main() {
int i = 0;
do {
i++;
if (i % 3 == 0)
continue;
printf("%d ", i);
} while (i < 9);
return 0;
}
A) 1 2 4 5 7 8
B) 1 2 4 5 7 8 9
C) 1 2 4 5 8 9
D) 1 2 4 7 8
Answer: A) 1 2 4 5 7 8
348 Predict the output:
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 3 5
B) 2 4
C) 1 2 3 4 5
D) 1 2 4 5
Answer: A) 1 3 5
349 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i = 0;
while (i < 7) {
i++;
if (i % 2 == 0)
continue;
printf("%d ", i);
}
return 0;
}
A) 1 3 5 7
B) 2 4 6
C) 1 2 3 4 5 6 7
D) 1 2 4 6
Answer: A) 1 3 5 7
350 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int i = 0;
while (i < 7) {
i++;
if (i % 2 == 0)
{
continue;
break;
}
printf("%d ", i);
}
return 0;
}
A) 1 3 5 7
B) 2 4 6
C) 1 2 3 4 5 6 7
D) Compilation Error
Answer: A) 1 3 5 7
Nested If Condition
351 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 5, y = 10;
if (x > 3) {
if (y > 5)
printf("Hello ");
else
printf("Hi ");
}
return 0;
}
A) Hello
B) Hi
C) Compilation Error
D) Undefined
Answer: A) Hello
352 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 3;
if (a > 4) {
if (b < 4)
printf("Good ");
else if (b == 3)
printf("Morning ");
}
return 0;
}
A) Good
B) Morning
C) Good Morning
D) No Output
Answer: A) Good
353 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 5, y = 15;
if (x > 3) {
if (y > 10)
printf("Yes ");
else
printf("No ");
}
return 0;
}
A) Yes
B) No
C) Yes No
D) No Output
Answer: A) Yes
354 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 2;
if (a > 4) {
if (b < 3)
printf("One ");
else
printf("Two ");
}
return 0;
}
A) One
B) Two
C) One Two
D) No Output
Answer: A) One
355 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 7, y = 9;
if (x > 6) {
if (y > 8)
printf("Alpha ");
else if (y == 9)
printf("Beta ");
}
return 0;
}
A) Alpha
B) Beta
C) Alpha Beta
D) No Output
Answer: A) Alpha
356 Predict the output:
#include <stdio.h>
int main() {
int a = 4, b = 5;
if (a > 3) {
if (b > 4)
printf("Gamma ");
else
printf("Delta ");
}
return 0;
}
A) Gamma
B) Delta
C) Gamma Delta
D) No Output
Answer: A) Gamma
357 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5) {
if (y == 5)
printf("Epsilon ");
else if (y < 5)
printf("Zeta ");
}
return 0;
}
A) Epsilon
B) Zeta
C) Epsilon Zeta
D) No Output
Answer: A) Epsilon
358 Predict the output:
#include <stdio.h>
int main() {
int a = 6, b = 3;
if (a > 5) {
if (b == 3)
printf("Eta ");
else
printf("Theta ");
}
return 0;
}
A) Eta
B) Theta
C) Eta Theta
D) No Output
Answer: A) Eta
359 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 8, y = 4;
if (x > 7) {
if (y == 4)
printf("Iota ");
else if (y > 3)
printf("Kappa ");
}
return 0;
}
A) Iota
B) Kappa
C) Iota Kappa
D) No Output
Answer: A) Iota
360 Predict the output:
#include <stdio.h>
int main() {
int a = 5, b = 4;
if (a > 4) {
if (b < 5)
printf("Lambda ");
else
printf("Mu ");
}
return 0;
}
A) Lambda
B) Mu
C) Lambda Mu
D) No Output
Answer: A) Lambda
361 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 12, y = 8;
if (x > 10) {
if (y > 7)
printf("Omega ");
else
printf("Psi ");
}
return 0;
}
A) Omega
B) Psi
C) Omega Psi
D) No Output
Answer: A) Omega
362 Predict the output:
#include <stdio.h>
int main() {
int a = 7, b = 2;
if (a > 6) {
if (b < 3)
printf("Rho ");
else if (b == 2)
printf("Sigma ");
}
return 0;
}
A) Rho
B) Sigma
C) Rho Sigma
D) No Output
Answer: A) Rho
363 What will be printed by the following code?
#include <stdio.h>
int main() {
int x = 15, y = 10;
if (x > 14) {
if (y == 10)
printf("Tau ");
else
printf("Upsilon ");
}
return 0;
}
A) Tau
B) Upsilon
C) Tau Upsilon
D) No Output
Answer: A) Tau
364 Predict the output:
#include <stdio.h>
int main() {
int a = 9, b = 5;
if (a > 8) {
if (b < 6)
printf("Phi ");
else
printf("Chi ");
}
return 0;
}
A) Phi
B) Chi
C) Phi Chi
D) No Output
Answer: A) Phi
365 What will be the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 16, y = 9;
if (x > 15) {
if (y > 8)
printf("Psi ");
else if (y == 9)
printf("Omega ");
}
return 0;
}
A) Psi
B) Omega
C) Psi Omega
D) No Output
Answer: A) Psi
Complex Nested Looping Statement
366 What will be the output of the following code?
#include <stdio.h>
int main() {
int i, j;
for (i = 0; i < 3; i++) {
for (j = i; j < 3; j++) {
printf("%d ", i);
}
}
return 0;
}
Options:
A) 0 0 0 1 1 2
B) 0 1 2 1 2 2
C) 0 1 2 0 1 2
D) 0 0 0 0 0 0
Answer: A) 0 0 0 1 1 2
367 What will be the output of the following code?
#include <stdio.h>
int main() {
int i, j;
for (i = 0; i < 3; i++) {
for (j = i; j < 3; j++) {
printf("%d ", j);
}
}
return 0;
}
Options:
A) 0 1 2 1 2 2
B) 0 1 2 0 1 2
C) 1 2 3 2 2 2
D) 0 0 0 1 1 2
Answer: A) 0 1 2 1 2 2
368 What is the output of the following code?
#include <stdio.h>
int main() {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3 - i; j++) {
printf("%d ", j);
}
}
return 0;
}
Options:
A) 0 1 2 0 1 0
B) 0 1 2 0 1
C) 0 1 2 1 2
D) 0 1 2 2 1 0
Answer: A) 0 1 2 0 1 0
369 What will the code below print?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = 3; j; j--) {
printf("%d ", i + j);
}
}
return 0;
}
Options:
A) 3 2 1 4 3 2 5 4 3
B) 4 3 2 3 2 1 2 1 0
C) 3 4 5 2 3 4 1 2 3
D) 4 5 6 3 4 5 2 3 4
Answer: A) 3 2 1 4 3 2 5 4 3
370 What's the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= i; j++) {
printf("%d ", i * j);
}
}
return 0;
}
Options:
A) 1 2 2 3 3 6
B) 1 2 3 2 4 6
C) 1 2 3 4 6 9
D) 1 2 4 3 6 9
Answer: D) 1 2 4 3 6 9
371 What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = 3; j > 0; j--) {
if (i == j) continue;
printf("%d%d ", i, j);
}
}
return 0;
}
Options:
A) 01 02 10 12 20 21
B) 01 02 10 20 21 22
C) 03 02 01 13 12 23 21
D) 01 02 11 20 21 22
Answer: C) 03 02 01 13 12 23 21
372 What is the output of the code below?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
printf("%d ", i * j);
if (i == 2 && j == 2)
break;
}
}
return 0;
}
Options:
A) 1 2 3 2 4 6
B) 1 2 3 2 4 6 3 6 9
C) 1 2 3 2 4 3 6 9
D) 1 2 2 4 3 6 3 6 9
Answer: C) 1 2 3 2 4 3 6 9
373 What will be the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 2; j++) {
printf("%d%d ", i, j);
if (i == j)
continue;
printf("%d%d ", j, i);
}
}
return 0;
}
Options:
A) 11 21 12 22
B) 11 12 21 21 12 22
C) 11 12 21 22
D) 11 12 12 11 21 22 22 21
Answer: B) 11 12 21 21 12 22
374 What is the output of the code below?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
printf("%d ", (i * j) % 2);
}
}
return 0;
}
Options:
A) 0 1 0 1 0 1 0 1 0
B) 0 0 0 0 1 0 0 0 0
C) 0 1 0 1 0 1 1 0 1
D) 1 0 1 0 1 0 1 0 1
Answer: B) 0 0 0 0 1 0 0 0 0
375 What will be the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = 3; j > 0; j--) {
printf("%d ", (i + j) % 2);
}
}
return 0;
}
Options:
A) 0 1 0 1 0 1 0 1 0
B) 1 0 1 0 1 0
C) 0 1 1 0 0 1
D) 1 0 0 1 1 0
Answer: A) 0 1 0 1 0 1 0 1 0
376 What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = 3; j >= 1; j--) {
if (i == j) continue;
printf("%d%d ", i, j);
}
}
return 0;
}
Options:
A) 12 13 21 23 31 32
B) 12 13 21 31 32 33
C) 13 12 23 21 32 31
D) 13 12 21 31 32 33
Answer: C) 13 12 23 21 32 31
377 What will be the output of the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i == j)
continue;
printf("%d ", i + j);
}
}
return 0;
}
Options:
A) 1 2 1 3 2 3
B) 0 1 2 1 2 0
C) 1 2 3 3 2 1
D) 0 1 2 2 1 0
Answer: A) 1 2 1 3 2 3
378 What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = i; j >= 0; j--) {
printf("%d ", j);
}
}
return 0;
}
Options:
A) 0 0 1 0 1 2
B) 0 1 2 1 0
C) 0 1 2 2 1 0
D) 0 1 0 2 1 0
Answer: D) 0 1 0 2 1 0
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = i; j <= 3; j++) {
printf("%d ", i * j);
}
}
return 0;
}
Options:
A) 1 2 3 4 6 9
B) 1 2 3 2 4 6
C) 1 1 2 1 2 3
D) 1 2 2 4 3 6
Answer: A) 1 2 3 4 6 9
379 What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = i; j >= 1; j--) {
printf("%d ", j);
}
}
return 0;
}
Options:
A) 1 1 2 1 2 3
B) 1 2 1 3 2 1
C) 1 2 3 3 2 1
D) 1 2 3 1 2
Answer: B) 1 2 1 3 2 1
380 What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 0; i < 3; i++) {
for (int j = i; j >= 0; j--) {
printf("%d ", j);
}
}
return 0;
}
Options:
A) 0 0 1 0 1 2
B) 0 1 2 1 0
C) 0 1 2 2 1 0
D) 0 1 0 2 1 0
Answer: D) 0 1 0 2 1 0
Arrays (Declaration, initialization, and accessing arrays)
381 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3};
printf("%d", arr[4]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) 3
D) Compiler Error
Answer: A) 0
382 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {0};
printf("%d", arr[4]);
return 0;
}
Options:
A) 0
B) 1
C) Garbage Value
D) Compiler Error
Answer: A
383 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2};
printf("%d", arr[2]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) 2
D) Compiler Error
Answer: A
384 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d", arr[0] + arr[4]);
return 0;
}
Options:
A) 5
B) 6
C) 6
D) 10
Answer: C) 6
385 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3};
printf("%d", arr[5]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) 3
D) Compiler Error
Answer: A) 0
386 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[3]++);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 6
Answer: B) 4
387 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", ++arr[1]);
return 0;
}
Options:
A) 2
B) 3
C) 4
D) 5
Answer: B) 3
388 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5];
printf("%d", arr[2]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) 2
D) Compiler Error
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", *(arr + 2));
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: C) 3
390 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[-1]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) Compiler Error
D) Undefined Behavior
Answer: A) 0
391 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", sizeof(arr) / sizeof(arr[0]));
return 0;
}
Options:
A) 5
B) 10
C) 4
D) 1
Answer: A) 5
392 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[5] + arr[0]);
return 0;
}
Options:
A) 1
B) 2
C) 5
D) Garbage Value
Answer: A) 1
393 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", *(arr));
return 0;
}
Options:
A) 1
B) 2
C) 0
D) Garbage Value
Answer: A) 1
394 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[4] - arr[3]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: A) 1
395 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[2] * 2);
return 0;
}
Options:
A) 2
B) 4
C) 6
D) 8
Answer: C) 6
396 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", 2[arr]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: C) 3
397 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3};
printf("%d", arr[2]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) Compiler Error
Answer: C) 3
398 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3};
printf("%d", arr[1]++);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: B) 2
399 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[3] - arr[1]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: B) 2
400 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[2] / 2);
return 0;
}
Options:
A) 0
B) 1
C) 1.5
D) 2
Answer: B) 1
Arrays (Multi-dimensional arrays)
401 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {{1, 2}, {3, 4}};
printf("%d", arr[1][0]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: C) 3
402 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][3] = {{1, 2, 3}, {4, 5}};
printf("%d", arr[1][1]);
return 0;
}
Options:
A) 2
B) 4
C) 5
D) Garbage Value
Answer: C) 5
403 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {1, 2, 3, 4};
printf("%d", arr[0][1]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: B) 2
404 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[][2] = {1, 2, 3, 4, 5, 6};
printf("%d", arr[2][1]);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 6
Answer: D) 6
405 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {{1}, {2}};
printf("%d", arr[1][0]);
return 0;
}
Options:
A) 0
B) 1
C) 2
D) Garbage Value
Answer: C) 2
406 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][3] = {1, 2, 3, 4, 5};
printf("%d", arr[1][2]);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 0
Answer: D) 0
407 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {0};
printf("%d", arr[1][1]);
return 0;
}
Options:
A) 0
B) Garbage Value
C) 1
D) 2
Answer: A) 0
408 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {1, 2, 3};
printf("%d", arr[1][1]);
return 0;
}
Options:
A) 0
B) 2
C) 3
D) Garbage Value
Answer: A) 0
409 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][3] = {{1}, {2, 3}};
printf("%d", arr[1][1]);
return 0;
}
Options:
A) 0
B) 2
C) 3
D) Garbage Value
Answer: C) 3
410 what will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][3] = {1, 2, 3, 4, 5};
printf("%d", arr[0][2]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) Garbage Value
Answer: C) 3
411 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[3][3] = {{1, 2}, {3, 4}, {5, 6}};
printf("%d", arr[2][1]);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 6
Answer: D) 6
412 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[][3] = {1, 2, 3, 4, 5, 6};
printf("%d", arr[1][2]);
return 0;
}
Options:
A) 2
B) 3
C) 5
D) 6
Answer: D) 6
413 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[3][2] = {1, 2, 3, 4, 5, 6};
printf("%d", arr[2][0]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 5
Answer: D) 5
414 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {1, 2, 3, 4};
printf("%d", arr[1][0] + arr[0][1]);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 6
Answer: C) 5
415 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][3] = {1, 2, 3, 4, 5, 6};
printf("%d", arr[1][1] * arr[0][2]);
return 0;
}
Options:
A) 6
B) 8
C) 15
D) 18
Answer: C) 15
416 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {1, 2, 3, 4};
printf("%d", arr[0][0] + arr[1][1]);
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 6
Answer: C) 5
417 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {{1}, {2}};
printf("%d", arr[1][0]);
return 0;
}
Options:
A) 0
B) 1
C) 2
D) Garbage Value
Answer: C) 2
418 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[2][2] = {1, 2, 3};
printf("%d", arr[0][1]);
return 0;
}
Options:
A) 0
B) 2
C) 3
D) Garbage Value
Answer: B) 2
419 What is the output of the following code?
#include <stdio.h>
int main() {
int arr[3][3] = {{1, 2}, {3, 4}, {5, 6}};
printf("%d", arr[0][2]);
return 0;
}
Options:
A) 0
B) 1
C) 2
D) Garbage Value
Answer: A) 0
420 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3][3] = {{1, 2}, {3, 4}, {5, 6}};
printf("%d", arr[2][2]);
return 0;
}
Options:
A) 0
B) 1
C) 6
D) Garbage Value
Answer: A) 0
Arrays (Multi
Dimensional arrays using string values)
421 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][5] = {"one", "two"};
printf("%c", arr[1][2]);
return 0;
}
Options:
A) n
B) t
C) o
D) w
Answer: C) o
422 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[2][6] = {"apple", "orange"};
printf("%c", arr[0][3]);
return 0;
}
Options:
A) p
B) l
C) e
D) a
Answer: B) l
423 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[][5] = {"cat", "dog", "cow"};
printf("%c", arr[2][1]);
return 0;
}
Options:
A) c
B) a
C) o
D) w
Answer: C) o
424 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[3][4] = {"car", "bus", "van"};
printf("%c", arr[1][2]);
return 0;
}
Options:
A) r
B) s
C) a
D) b
Answer: B) s
425 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][5] = {"left", "right"};
printf("%c", arr[0][0]);
return 0;
}
Options:
A) l
B) r
C) e
D) f
Answer: A) l
426 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[2][6] = {"apple", "orange"};
printf("%s", arr[1]);
return 0;
}
Options:
A) apple
B) orange
C) pples
D) range
Answer: B) orange
427 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[3][5] = {"dog", "cat", "bird"};
printf("%c", arr[2][3]);
return 0;
}
Options:
A) d
B) t
C) r
D) g
Answer: A) d
428 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[3][6] = {"mouse", "rat", "frog"};
printf("%c", arr[0][4]);
return 0;
}
Options:
A) u
B) s
C) e
D) o
Answer: C) e
429 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][5] = {"moon", "star"};
printf("%s", arr[1]);
return 0;
}
Options:
A) moon
B) star
C) oon
D) tar
Answer: B) star
430 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[][5] = {"lion", "tiger", "bear"};
printf("%c", arr[2][1]);
return 0;
}
Options:
A) l
B) i
C) g
D) e
Answer: D) e
431 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[3][5] = {"wolf", "deer", "elk"};
printf("%c", arr[0][2]);
return 0;
}
Options:
A) l
B) f
C) e
D) r
Answer: A) l
432 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[][5] = {"fish", "shark", "whale"};
printf("%c", arr[1][3]);
return 0;
}
Options:
A) f
B) i
C) s
D) r
Answer: D) r
433 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][6] = {"snake", "lizard"};
printf("%c", arr[1][4]);
return 0;
}
Options:
A) s
B) n
C) a
D) r
Answer: D) r
434 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[3][6] = {"zebra", "horse", "donkey"};
printf("%s", arr[2]);
return 0;
}
Options:
A) zebra
B) horse
C) donkey
D) ebra
Answer: C) donkey
435 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][5] = {"tree", "plant"};
printf("%c", arr[0][3]);
return 0;
}
Options:
A) t
B) r
C) a
D) e
Answer: D) e
436 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[][5] = {"bird", "duck", "swan"};
printf("%c", arr[0][1]);
return 0;
}
Options:
A) i
B) b
C) r
D) d
Answer: A) i
437 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[3][5] = {"frog", "toad", "newt"};
printf("%c", arr[2][0]);
return 0;
}
Options:
A) f
B) t
C) n
D) w
Answer: C) n
438 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[][6] = {"snake", "lizard", "turtle"};
printf("%c", arr[1][3]);
return 0;
}
Options:
A) s
B) n
C) a
D) r
Answer: C) a
439 What is the output of the following code?
#include <stdio.h>
int main() {
char arr[2][5] = {"moon", "star"};
printf("%s", arr[0]);
return 0;
}
Options:
A) moon
B) star
C) moonstar
D) m
Answer: A) moon
440 What will be the output of the following code?
#include <stdio.h>
int main() {
char arr[][6] = {"apple", "banana", "cherry"};
printf("%c", arr[2][5]);
return 0;
}
Options:
A) a
B) p
C) e
D) y
Answer: D) y
Array operations on functions
441 What is the output of the following code?
#include <stdio.h>
void display(int arr[]) {
printf("%d", arr[1]);
}
int main() {
int a[] = {1, 2, 3};
display(a);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) Compiler Error
Answer: B) 2
442 What will be the output of the following code?
#include <stdio.h>
void modify(int arr[]) {
arr[1] = 5;
}
int main() {
int a[] = {1, 2, 3};
modify(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 5
Answer: D) 5
443 What is the output of the following code?
#include <stdio.h>
void change(int *arr) {
arr[2] = 10;
}
int main() {
int a[] = {1, 2, 3};
change(a);
printf("%d", a[2]);
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 10
Answer: D) 10
444 What will be the output of the following code?
#include <stdio.h>
void update(int *a) {
a++;
*a = 7;
}
int main() {
int arr[] = {3, 4, 5};
update(arr);
printf("%d", arr[1]);
return 0;
}
Options:
A) 3
B) 4
C) 7
D) Undefined
Answer: C) 7
445 What is the output of the following code?
#include <stdio.h>
void process(int *arr) {
arr[0] = 6;
}
int main() {
int a[] = {4, 5, 6};
process(a);
printf("%d", a[0]);
return 0;
}
Options:
A) 4
B) 5
C) 6
D) Compiler Error
Answer: C) 6
446 What will be the output of the following code?
#include <stdio.h>
void arrayFunc(int arr[]) {
arr[0] = 8;
}
int main() {
int a[] = {2, 3, 4};
arrayFunc(a);
printf("%d", a[0]);
return 0;
}
Options:
A) 2
B) 3
C) 4
D) 8
Answer: D) 8
447 What is the output of the following code?
#include <stdio.h>
void modifyArray(int *arr) {
arr++;
*arr = 9;
}
int main() {
int a[] = {5, 6, 7};
modifyArray(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 5
B) 6
C) 7
D) 9
Answer: D) 9
448 What will be the output of the following code?
#include <stdio.h>
void arrayFunction(int arr[3]) {
arr[2] = 11;
}
int main() {
int a[] = {7, 8, 9};
arrayFunction(a);
printf("%d", a[2]);
return 0;
}
Options:
A) 7
B) 8
C) 9
D) 11
Answer: D) 11
449 What is the output of the following code?
#include <stdio.h>
void arrayUpdate(int *arr) {
arr[1] = 12;
}
int main() {
int a[] = {10, 11, 12};
arrayUpdate(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 10
B) 11
C) 12
D) 13
Answer: C) 12
450 What will be the output of the following code?
#include <stdio.h>
void changeArray(int arr[]) {
arr[0] = 13;
}
int main() {
int a[] = {15, 16, 17};
changeArray(a);
printf("%d", a[0]);
return 0;
}
Options:
A) 13
B) 15
C) 16
D) 17
Answer: A) 13
451 What is the output of the following code?
#include <stdio.h>
void processArray(int arr[2]) {
arr[1] = 14;
}
int main() {
int a[] = {18, 19};
processArray(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 18
B) 19
C) 14
D) Compiler Error
Answer: C) 14
452 What will be the output of the following code?
#include <stdio.h>
void modifyFunc(int arr[5]) {
arr[3] = 20;
}
int main() {
int a[] = {21, 22, 23, 24};
modifyFunc(a);
printf("%d", a[3]);
return 0;
}
Options:
A) 21
B) 22
C) 23
D) 20
Answer: D) 20
453 What is the output of the following code?
#include <stdio.h>
void arrayManipulate(int arr[]) {
arr[2] = 25;
}
int main() {
int a[4] = {26, 27, 28, 29};
arrayManipulate(a);
printf("%d", a[2]);
return 0;
}
Options:
A) 26
B) 27
C) 28
D) 25
Answer: D) 25
454 What will be the output of the following code?
#include <stdio.h>
void arrayChange(int arr[5]) {
arr[4] = 30;
}
int main() {
int a[] = {31, 32, 33, 34};
arrayChange(a);
printf("%d", a[4]);
return 0;
}
Options:
A) 31
B) 32
C) 33
D) 30
Answer: D) 30
455 What is the output of the following code?
#include <stdio.h>
void updateArray(int arr[]) {
arr[1] = 35;
}
int main() {
int a[3] = {36, 37, 38};
updateArray(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 36
B) 37
C) 35
D) 38
Answer: C) 35
456 What will be the output of the following code?
#include <stdio.h>
void arrayEdit(int arr[]) {
arr[0] = 40;
}
int main() {
int a[] = {41, 42, 43};
arrayEdit(a);
printf("%d", a[0]);
return 0;
}
Options:
A) 40
B) 41
C) 42
D) 43
Answer: A) 40
457 What is the output of the following code?
#include <stdio.h>
void changeArray(int arr[]) {
arr[2] = 45;
}
int main() {
int a[4] = {46, 47, 48};
changeArray(a);
printf("%d", a[2]);
return 0;
}
Options:
A) 46
B) 47
C) 48
D) 45
Answer: D) 45
458 What will be the output of the following code?
#include <stdio.h>
void arrayModify(int arr[4]) {
arr[3] = 50;
}
int main() {
int a[] = {51, 52, 53};
arrayModify(a);
printf("%d", a[3]);
return 0;
}
Options:
A) 51
B) 52
C) 53
D) 50
Answer: D) 50
459 What is the output of the following code?
#include <stdio.h>
void manipulate(int arr[]) {
arr[1] = 55;
}
int main() {
int a[3] = {56, 57, 58};
manipulate(a);
printf("%d", a[1]);
return 0;
}
Options:
A) 56
B) 55
C) 57
D) 58
Answer: B) 55
460 What will be the output of the following code?
#include <stdio.h>
void editArray(int arr[3]) {
arr[2] = 60;
}
int main() {
int a[] = {61, 62};
editArray(a);
printf("%d", a[2]);
return 0;
}
Options:
A) 61
B) 62
C) 60
D) Compiler Error
Answer: C) 60
Functions (Function declaration and definition)
461 What is the output of the following code?
#include <stdio.h>
int func(int x);
int main() {
printf("%d", func(5));
return 0;
}
int func(int x) {
return x * x;
}
Options:
A) 5
B) 10
C) 25
D) Compiler Error
Answer: C) 25
462 What will be the output of the following code?
#include <stdio.h>
int demo();
int main() {
printf("%d", demo());
return 0;
}
int demo() {
return 100;
}
Options:
A) 0
B) 100
C) Garbage Value
D) Compiler Warning
Answer: B) 100
463 What is the output of the following code?
#include <stdio.h>
void display();
int main() {
display();
return 0;
}
void display() {
printf("Hello, World!");
}
Options:
A) Hello, World!
B) Compiler Error
C) Segmentation Fault
D) No output
#include <stdio.h>
void show() {
printf("C is ");
}
int main() {
void (*ptr)() = show;
(*ptr)();
printf("powerful.");
return 0;
}
Options:
A) C is powerful.
B) powerful.
C) C is
D) Compiler Error
Answer: A) C is powerful.
465 What is the output of the following code?
#include <stdio.h>
void greet() {
printf("Greetings from C!");
}
int main() {
void (*function_ptr)() = greet;
function_ptr();
return 0;
}
Options:
A) Greetings from C!
B) Compiler Error
C) Greetings from
D) No output
#include <stdio.h>
void sayHello() {
printf("Hello, ");
}
int main() {
void (*ptr)() = sayHello;
(*ptr)();
printf("World!");
return 0;
}
Options:
A) Hello, World!
B) Hello,
C) World!
D) Compiler Error
#include <stdio.h>
int main() {
printf("%d", multiply(3, 4));
return 0;
}
Answer: B) 12
468 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", calculate(10));
return 0;
}
int calculate(int x) {
return x + 5;
}
Options:
A) 5
B) 10
C) 15
D) Compiler Error
Answer: C) 15
469 What is the output of the following code?
#include <stdio.h>
int main() {
printf("%d", add(7, 8));
return 0;
}
Answer: C) 15
470 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", product(6, 7));
return 0;
}
Answer: B) 42
471 What is the output of the following code?
#include <stdio.h>
void displayMessage() {
printf("This is a function.");
}
int main() {
displayMessage();
return 0;
}
Options:
A) This is a function.
B) main()
C) Compiler Error
D) No output
#include <stdio.h>
void show() {
printf("Function call!");
}
int main() {
void (*fptr)() = show;
fptr();
return 0;
}
Options:
A) Function call!
B) show
C) main()
D) Compiler Error
Answer: A) Function call!
473 What is the output of the following code?
#include <stdio.h>
void hello();
int main() {
hello();
return 0;
}
void hello() {
printf("Greetings!");
}
Options:
A) hello
B) Greetings!
C) main()
D) No output
Answer: B) Greetings!
474 What will be the output of the following code?
#include <stdio.h>
void printFunc() {
printf("Function called.");
}
int main() {
void (*funcPtr)() = printFunc;
funcPtr();
return 0;
}
Options:
A) Function called.
B) printFunc
C) main()
D) Compiler Error
#include <stdio.h>
void welcome() {
printf("Welcome to C!");
}
int main() {
welcome();
return 0;
}
Options:
A) Welcome to C!
B) welcome
C) main()
D) No output
Answer: A) Welcome to C!
476 What will be the output of the following code?
#include <stdio.h>
void display() {
printf("Display function.");
}
int main() {
void (*ptr)() = display;
ptr();
return 0;
}
Options:
A) Display function.
B) display
C) main()
D) Compiler Error
#include <stdio.h>
void function() {
printf("Function called.");
}
int main() {
function();
return 0;
}
Options:
A) Function called.
B) function
C) main()
D) No output
#include <stdio.h>
void printFunction() {
printf("Printed.");
}
int main() {
void (*fptr)() = printFunction;
fptr();
return 0;
}
Options:
A) Printed.
B) printFunction
C) main()
D) Compiler Error
Answer: A) Printed.
479 What is the output of the following code?
#include <stdio.h>
void execute() {
printf("Execute function.");
}
int main() {
execute();
return 0;
}
Options:
A) Execute function.
B) execute
C) main()
D) No output
#include <stdio.h>
void functionCall() {
printf("Function invoked.");
}
int main() {
void (*func)() = functionCall;
func();
return 0;
}
Options:
A) Function invoked.
B) functionCall
C) main()
D) Compiler Error
#include <stdio.h>
int main() {
printf("%d", multiply(3, 4));
return 0;
}
Options:
A) 7
B) 12
C) 34
D) Compiler Error
Answer: B) 12
482 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%.2f", compute(5.0, 2.0));
return 0;
}
Options:
A) 2.50
B) 2
C) 2.0
D) 2.5
Answer: A) 2.50
483 What is the output of the following code?
#include <stdio.h>
int main() {
greet("Alice");
return 0;
}
Options:
A) Hello, Alice!
B) Hello, name!
C) Hello,
D) Compiler Error
#include <stdio.h>
int main() {
printf("%d", power(2, 3));
return 0;
}
Options:
A) 5
B) 6
C) 8
D) 9
Answer: C) 8
485 What is the output of the following code?
#include <stdio.h>
float average(int nums[], int size) {
float sum = 0.0;
for (int i = 0; i < size; i++) {
sum += nums[i];
}
return sum / size;
}
int main() {
int values[] = {1, 2, 3, 4, 5};
printf("%.2f", average(values, 5));
return 0;
}
Options:
A) 2.50
B) 3.00
C) 3
D) 2.00
Answer: B) 3.00
486 What will be the output of the following code?
#include <stdio.h>
void display(int n) {
printf("%d", n);
}
int main() {
int x = 10;
display(x++);
return 0;
}
Options:
A) 10
B) 11
C) 9
D) 12
Answer: A) 10
487 What is the output of the following code?
#include <stdio.h>
int main() {
int result = sum(3, 4) * 2;
printf("%d", result);
return 0;
}
Options:
A) 14
B) 15
C) 10
D) 8
Answer: A) 14
488 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 3;
printf("%d", compute(x, y++));
return 0;
}
Options:
A) 2
B) 3
C) 4
D) 5
Answer: A) 2
489 What is the output of the following code?
#include <stdio.h>
int main() {
printf("%d", absolute(-7));
return 0;
}
Options:
A) -7
B) 7
C) 0
D) 1
Answer: B) 7
490 What will be the output of the following code?
#include <stdio.h>
void modify(int *a) {
*a = *a + 1;
}
int main() {
int num = 5;
modify(&num);
printf("%d", num);
return 0;
}
Options:
A) 4
B) 5
C) 6
D) 7
Answer: C) 6
491 What is the output of the following code?
#include <stdio.h>
int main() {
printf("%.2f", calculate(10.0, 3.0));
return 0;
}
Options:
A) 3.00
B) 3
C) 3.33
D) 3.0
Answer: C) 3.33
492 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", square(3) + square(4));
return 0;
}
Options:
A) 25
B) 7
C) 12
D) 16
Answer: A) 25
493 What is the output of the following code?
#include <stdio.h>
int main() {
printValue(2 * 3 + 4);
return 0;
}
Options:
A) 10
B) 14
C) 9
D) 12
Answer: A) 10
494 What will be the output of the following code?
#include <stdio.h>
int main() {
int result = operation(2, 3) + operation(1, 2);
printf("%d", result);
return 0;
}
Options:
A) 9
B) 13
C) 17
D) 18
Answer: D) 18
495 What is the output of the following code?
#include <stdio.h>
int main() {
displaySum(1, 2) * 2;
return 0;
}
Options:
A) 3
B) 6
C) 4
D) 2
Answer: A) 3
496 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%.2f", calculateValue(5.0, 3.0));
return 0;
}
Options:
A) 4.0
B) 4
C) 4.50
D) 2.50
Answer: A) 4.0
497 What is the output of the following code?
#include <stdio.h>
int main() {
printMessage("Hello" + 2);
return 0;
}
Options:
A) llo
B) Hello
C) Error
D) Undefined
Answer: A) llo
498 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = findDifference(8, 3);
printf("%d", x);
return 0;
}
Options:
A) 5
B) 3
C) 8
D) -5
Answer: A) 5
499 What is the output of the following code?
#include <stdio.h>
void displayValue(int n) {
printf("%d", n);
}
int main() {
displayValue(2 + 3 * 4);
return 0;
}
Options:
A) 20
B) 14
C) 15
D) 23
Answer: B) 14
500 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%.2f", averageValue(4, 5));
return 0;
}
Options:
A) 4
B) 4.00
C) 4.50
D) 5
Answer: C) 4.50
Recursive functions
501 What will be the output of the following recursive function?
#include <stdio.h>
int recursive(int n) {
if (n <= 0)
return 0;
return 1 + recursive(n - 1);
}
int main() {
printf("%d", recursive(5));
return 0;
}
Options:
A) 0
B) 1
C) 5
D) 15
Answer: C) 5
502 What is the output of the following recursive function call?
#include <stdio.h>
void print(int n) {
if (n > 3)
print(--n);
printf("%d", n);
}
int main() {
print(5);
return 0;
}
Options:
A) 1
B) 123
C) 334
D) 4321
Answer: C) 334
503 What will be the output of the following recursive function?
#include <stdio.h>
int factorial(int n) {
if (n <= 1)
return 1;
return n * factorial(n - 1);
}
int main() {
printf("%d", factorial(4));
return 0;
}
Options:
A) 4
B) 16
C) 24
D) 120
Answer: C) 24
504 What is the output of the following recursive function?
#include <stdio.h>
void mystery(int n) {
if (n > 0) {
mystery(--n);
printf("%d ", n);
mystery(--n);
}
}
int main() {
mystery(4);
return 0;
}
Options:
A) 0 1 2 3
B) 0 1 2 0 3 0 1
C) 3 2 1 0
D) 3 2 1 0 1 2 1 3
Answer: B) 0 1 2 0 3 0 1
505 What will be the output of the following recursive function?
#include <stdio.h>
int main() {
printf("%d", compute(3, 4));
return 0;
}
Options:
A) 7
B) 10
C) 12
D) 15
Answer: C) 12
506 What is the output of the following recursive function call?
#include <stdio.h>
int mystery(int n) {
if (n <= 0)
return 0;
return mystery(n - 2) + n;
}
int main() {
printf("%d", mystery(5));
return 0;
}
Options:
A) 6
B) 7
C) 8
D) 9
Answer: D) 9
507 What will be the output of the following recursive function?
#include <stdio.h>
int fun(int n) {
if (n == 0)
return 0;
return 2 * fun(n - 1) + n;
}
int main() {
printf("%d", fun(3));
return 0;
}
Options:
A) 0
B) 4
C) 10
D) 11
Answer: D) 11
508 What is the output of the following recursive function?
#include <stdio.h>
int main() {
printf("%d", calculate(4, 7));
return 0;
}
Options:
A) 11
B) 12
C) 13
D) 14
Answer: A) 11
509 What will be the output of the following recursive function?
#include <stdio.h>
int fibonacci(int n) {
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
printf("%d", fibonacci(5));
return 0;
}
Options:
A) 3
B) 4
C) 5
D) 8
Answer: C) 5
510 What is the output of the following recursive function?
#include <stdio.h>
int mystery(int n) {
if (n == 0)
return 1;
return 2 * mystery(n - 1);
}
int main() {
printf("%d", mystery(3));
return 0;
}
Options:
A) 2
B) 4
C) 6
D) 8
Answer: D) 8
511 What will be the output of the following recursive function?
#include <stdio.h>
int sum(int n) {
if (n == 0)
return 0;
return n + sum(n / 2);
}
int main() {
printf("%d", sum(8));
return 0;
}
Options:
A) 4
B) 8
C) 12
D) 15
Answer: D) 15
512 What is the output of the following recursive function?
#include <stdio.h>
int mystery(int n) {
if (n <= 1)
return 1;
return mystery(n - 1) + mystery(n - 2);
}
int main() {
printf("%d", mystery(4));
return 0;
}
Options:
A) 2
B) 3
C) 5
D) 8
Answer: C) 5
513 What will be the output of the following recursive function?
#include <stdio.h>
void fun(int n) {
if (n > 1) {
fun(n / 2);
fun(n / 2);
}
printf("*");
}
int main() {
fun(3);
return 0;
}
Options:
A) **
B) ***
C) *****
D) ******
Answer: B
514 What is the output of the following recursive function?
#include <stdio.h>
int mystery(int n) {
if (n == 1)
return 1;
return 1 + mystery(n / 2);
}
int main() {
printf("%d", mystery(8));
return 0;
}
Options:
A) 1
B) 2
C) 3
D) 4
Answer: D
515 What will be the output of the following recursive function?
#include <stdio.h>
void display(int n) {
if (n > 0) {
display(n / 2);
printf("%d", n % 2);
}
}
int main() {
display(10);
return 0;
}
Options:
A) 0101
B) 0011
C) 1010
D) 1101
Answer: C
516 What is the output of the following recursive function?
#include <stdio.h>
int mystery(int n) {
if (n <= 1)
return n;
return mystery(n - 1) + mystery(n - 2);
}
int main() {
printf("%d", mystery(5));
return 0;
}
Options:
A) 4
B) 5
C) 6
D) 8
Answer: B
517 What will be the output of the following recursive function?
#include <stdio.h>
int evaluate(int n) {
if (n <= 0)
return 1;
else
return evaluate(n - 2) * n;
}
int main() {
printf("%d", evaluate(4));
return 0;
}
Options:
A) 2
B) 8
C) 12
D) 24
Answer: B
518 What is the output of the following recursive function?
#include <stdio.h>
int func(int n) {
if (n == 0)
return 0;
else if (n % 2 == 0)
return func(n / 2);
else
return 1 + func(n - 1);
}
int main() {
printf("%d", func(5));
return 0;
}
Options:
A) 2
B) 3
C) 4
D) 5
Answer: A
519 What will be the output of the following recursive function?
#include <stdio.h>
int calculate(int n) {
if (n == 0)
return 0;
return n + calculate(n / 2);
}
int main() {
printf("%d", calculate(7));
return 0;
}
Options:
A) 7
B) 9
C) 11
D) 12
Answer: C
520 What is the output of the following recursive function?
#include <stdio.h>
int mystery(int n) {
if (n < 2)
return n;
else
return mystery(n - 2) + mystery(n - 1);
}
int main() {
printf("%d", mystery(6));
return 0;
}
Options:
A) 5
B) 6
C) 7
D) 8
Answer: D
Math Standard library functions
521 What is the output of the following code snippet?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", ceil(5.3) + floor(5.7));
return 0;
}
Options:
A) 11.0
B) 11
C) 10.0
D) 10
Answer: A
522 What will be the output of the following code?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", pow(2, 3));
return 0;
}
Options:
A) 6
B) 8.00
C) 9
D) 2.83
Answer: B
523 What is the output of the following code nippet?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", sqrt(16));
return 0;
}
Options:
A) 4.00
B) 4
C) 16
D) 2
Answer: A
524 What will be the output of the following code?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", fabs(-4.5));
return 0;
}
Options:
A) 4.5
B) -4.5
C) 5
D) -5
Answer: A
525 What is the output of the following code snippet?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", log10(100));
return 0;
}
Options:
A) 1.00
B) 2.00
C) 10
D) 100
Answer: B
526 What will be the output of the following code?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", sin(3.14159 / 2));
return 0;
}
Options:
A) 0.50
B) 1.00
C) 0
D) -1
Answer: B
527 What is the output of the following code snippet?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", tan(0));
return 0;
}
Options:
A) 0.00
B) 1
C) 0.50
D) Undefined
Answer: A
528 What will be the output of the following code?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", exp(1));
return 0;
}
Options:
A) 1.00
B) 2.00
C) 2.72
D) 3
Answer: C
529 What is the output of the following code snippet?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", atan(1) * 180 / 3.14159);
return 0;
}
Options:
A) 45.00
B) 30
C) 60
D) 90
Answer: A
530 What will be the output of the following code?
#include <stdio.h>
#include <math.h>
int main() {
printf("%.2f", round(5.49));
return 0;
}
Options:
A) 5.00
B) 5
C) 6
D) 6.00
Answer: A
String Functions
531 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "Hello";
char str2[] = "World";
strcat(str1, str2);
printf("%s", str1);
return 0;
}
Options:
A. HelloWorld
B. Hello
C. World
D. Compile Error
Answer: A
532 Which function can be used to compare two strings for equality?
Options:
A. strcmp()
B. strcpy()
C. strcat()
D. strlen()
Answer: A
533 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "OpenAI";
printf("%c", str[6]);
return 0;
}
Options:
A. OpenAI
B. A
C. Null character
D. Undefined behavior
Answer: C
534 Which function is used to find the length of a string?
Options:
A. strlen()
B. strcat()
C. strcmp()
D. strcpy()
Answer: A
535 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Welcome";
printf("%d", strlen(str));
return 0;
}
Options:
A. 7
B. 8
C. 9
D. Compile Error
Answer: A
536 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "Hello";
char str2[] = "World";
printf("%s", strcpy(str1, str2));
return 0;
}
Options:
A. Hello
B. World
C. HelloWorld
D. Compile Error
Answer: B
537 Which function can be used to find the first occurrence of a character in a
string?
Options:
A. strchr()
B. strstr()
C. strrchr()
D. strcmp()
Answer: A
538 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "C PROGRAMMING";
printf("%s", strchr(str, 'A'));
return 0;
}
Options:
A. C PROGRAMMING
B. A
C. AMMING
D. Null
Answer: C
539 What does the strcpy() function return?
Options:
A. Pointer to the source string
B. Pointer to the destination string
C. Length of the source string
D. Length of the destination string
Answer: B
540 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello";
printf("%s", strrev(str));
return 0;
}
Options:
A. olleH
B. elloH
C. Hello
D. Compile Error
Answer: D
541 Which function is used to concatenate two strings?
Options:
A. strcat()
B. strcpy()
C. strcmp()
D. strlen()
Answer: A
542 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "Hello";
char str2[] = "World";
printf("%d", strcmp(str1, str2));
return 0;
}
Options:
A. 0
B. -1
C. -15
D. Compile Error
Answer: C
543 Which function can be used to find the last occurrence of a character in a
string?
Options:
A. strchr()
B. strstr()
C. strrchr()
D. strcmp()
Answer: C
544 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "C PROGRAMMING";
printf("%s", strrchr(str, 'A'));
return 0;
}
Options:
A. C PROGRAMMING
B. AMMING
C. A
D. Null
Answer: B
545 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "Hello";
char str2[] = "World";
strncpy(str1, str2, 3);
printf("%s", str1);
return 0;
}
Options:
A. Hello
B. World
C. Worlo
D. Compile Error
Answer: C
546 Which function is used to find a substring in a string?
Options:
A. strcat()
B. strcpy()
C. strcmp()
D. strstr()
Answer: D
547 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello";
printf("%d", strlen(str + 2));
return 0;
}
Options:
A. 5
B. 3
C. 2
D. Compile Error
Answer: B
548 Which function is used to convert lowercase characters to uppercase in a
string?
Options:
A. strupr()
B. tolower()
C. toupper()
D. strlwr()
Answer: C
549 What will be the output of the following code?
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "C PROGRAMMING";
printf("%s", strlwr(str));
return 0;
}
Options:
A. C PROGRAMMING
B. c programming
C. C Programming
D. Compile Error
Answer: D
550 Which function is used to reverse a string?
Options:
A. strrev()
B. reverse()
C. revstr()
D. invert()
Answer: A
Typedef,Enumerations,Command-line arguments
551 What is the size of the short int data type in C on most systems?
Options:
A. 2 bytes
B. 4 bytes
C. 8 bytes
D. Depends on the system
Answer: A
552 What does the typedef keyword allow you to do?
Options:
A. Define a new data type name
B. Declare a variable
C. Define a function
D. Include a library
Answer: A
553 What will be the output of the following code?
#include <stdio.h>
typedef int* IntPtr;
int main() {
IntPtr x, y;
printf("%lu", sizeof(x));
return 0;
}
Options:
A. 4
B. 8
C. Error
D. Undefined
Answer: B
554 What does the enumeration in C allow you to do?
Options:
A. Define a new data type with a set of named constants
B. Define a function
C. Include a library
D. Declare a variable
Answer: A
555 What will be the output of the following code?
#include <stdio.h>
enum Days {SUN, MON, TUE};
int main() {
printf("%d", SUN);
return 0;
}
Options:
A. 0
B. 1
C. 2
D. SUN
Answer: A
556 Which bitwise operator is used to shift bits to the left?
Options:
A. <<
B. >>
C. &
D. |
Answer: A
557 What will be the output of the following code?
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("%s", argv[0]);
return 0;
}
Options:
A. The name of the program
B. NULL
C. Error
D. Undefined
Answer: A
558 What is the purpose of the argc argument in the main function?
Options:
A. Number of arguments passed to the program
B. Name of the program
C. Type of the program
D. Number of functions
Answer: A
559 What does the -- operator do when applied to an integer?
Options:
A. Decrements the value by 1
B. Decrements the value by 2
C. Increments the value by 1
D. Increments the value by 2
Answer: A
560 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
x ^= y ^= x ^= y;
printf("%d %d", x, y);
return 0;
}
Options:
A. 5 10
B. 10 5
C. 0 5
D. 5 0
Answer: B
561 Which bitwise operator is used to perform a bitwise AND operation?
Options:
A. &
B. |
C. ^
D. ~
Answer: A
562 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x << 1);
return 0;
}
Options:
A. 2
B. 5
C. 10
D. 20
Answer: C
563 What is the purpose of the -- operator when used as a postfix (x--)?
Options:
A. Decrements the value after evaluation
B. Decrements the value before evaluation
C. Increments the value after evaluation
D. Increments the value before evaluation
Answer: A
564 Which keyword is used to define an enumeration in C?
Options:
A. enum
B. typedef
C. enumdef
D. type
Answer: A
565 What will be the output of the following code?
#include <stdio.h>
enum {ONE, TWO, THREE};
int main() {
printf("%d", TWO + 1);
return 0;
}
Options:
A. 2
B. 3
C. 4
D. Compile Error
Answer: A
566 What does the sizeof operator return?
Options:
A. Size in bytes of a variable or data type
B. Value of a variable
C. Type of a variable
D. Address of a variable
Answer: A
567 Which bitwise operator is used to perform a bitwise OR operation?
Options:
A. |
B. &
C. ^
D. ~
Answer: A
568 What will be the output of the following code?
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("%s", argv[1]);
return 0;
}
Options:
A. The first argument passed to the program
B. The name of the program
C. Error
D. Undefined
Answer: A
569 What is the main advantage of using enumerations in C?
Options:
A. Improve readability
B. Reduce memory usage
C. Increase execution speed
D. Simplify complex calculations
Answer: A
570 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++ + ++x);
return 0;
}
Options:
A. 11
B. 12
C. 13
D. 14
Answer: B
571 What is the primary use of bit manipulation in C?
Options:
A. String manipulation
B. Numeric operations
C. Memory management
D. Flow control
Answer: B
572 Which bitwise operator is used to perform a bitwise XOR operation?
Options:
A. ^
B. &
C. |
D. ~
Answer: A
573 What will be the output of the following code?
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("%d", argc);
return 0;
}
Options:
A. Number of command-line arguments passed
B. Always 1
C. Always 0
D. Number of functions
Answer: B
574 Which bitwise operator is used to invert all bits in an integer?
Options:
A. ~
B. &
C. |
D. ^
Answer: A
575 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x & 3);
return 0;
}
Options:
A. 0
B. 1
C. 2
D. 3
Answer: B
Pointers: Basics
576 What is the size of a pointer in C on a 64-bit system?
Options:
A. 2 bytes
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer: C
577 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 10;
int *ptr = &x;
printf("%p", ptr);
return 0;
}
Options:
A. Address of x
B. 10
C. 0
D. Compile Error
Answer: A
578 What does the & operator return?
Options:
A. Value of a variable
B. Address of a variable
C. Size of a variable
D. Type of a variable
Answer: B
579 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3};
printf("%d", *arr);
return 0;
}
Options:
A. 1
B. 2
C. 3
D. Address of the first element
Answer: A
580 Which operator is used to access the value pointed by a pointer?
Options:
A. *
B. ->
C. &
D. .
Answer: A
581 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
int *ptr = &x;
*ptr = 10;
printf("%d", x);
return 0;
}
Options:
A. 5
B. 10
C. 0
D. Compile Error
Answer: B
582 What is the value of a pointer that is not initialized?
Options:
A. NULL
B. 0
C. Garbage value
D. 1
Answer: C
583 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {10, 20, 30};
int *ptr = arr;
printf("%d", *(ptr + 2));
return 0;
}
Options:
A. 10
B. 20
C. 30
D. Compile Error
Answer: C
584 Which operator is used to declare a pointer?
Options:
A. *
B. &
C. ->
D. .
Answer: A
585 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
int *ptr1 = &x;
int **ptr2 = &ptr1;
printf("%d", **ptr2);
return 0;
}
Options:
A. 5
B. Address of x
C. NULL
D. Compile Error
Answer: A
586 What does the expression ptr++ do?
Options:
A. Moves the pointer to the next memory location
B. Decrements the pointer value by 1
C. Dereferences the pointer
D. Multiplies the pointer value by 2
Answer: A
587 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
printf("%d", *(arr + 1));
return 0;
}
Options:
A. 1
B. 2
C. 3
D. Compile Error
Answer: B
588 What is the purpose of a null pointer?
Options:
A. Point to the first element of an array
B. Indicate that the pointer doesn't point to any memory location
C. Point to the last element of an array
D. Store the size of an array
Answer: B
589 What does the sizeof operator return for a pointer?
Options:
A. Size of the data type the pointer points to
B. Size of the pointer itself
C. Total size of memory allocated to the pointer
D. Size of the system memory
Answer: B
590 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 10;
int *p = &x;
*p += 5;
printf("%d", x);
return 0;
}
Options:
A. 10
B. 15
C. 5
D. Compile Error
Answer: B
591 Which pointer value is represented by 0?
Options:
A. NULL pointer
B. Garbage pointer
C. Valid memory address
D. Base address of the program
Answer: A
592 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
int *p = &x;
printf("%d", p[0]);
return 0;
}
Options:
A. 0
B. 5
C. Garbage value
D. Compile Error
Answer: B
593 What is the effect of the expression ptr = ptr + 1?
Options:
A. Increases the value of ptr by 1
B. Decreases the value of ptr by 1
C. Moves ptr to the next memory location of its type
D. Doesn't change the value of ptr
Answer: C
594 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {10, 20, 30};
int *ptr = arr;
printf("%d", ptr[2]);
return 0;
}
Options:
A. 10
B. 20
C. 30
D. Compile Error
Answer: C
595 What does the * operator signify when declaring a pointer?
Options:
A. Pointer declaration
B. Multiplication operator
C. Dereferencing operator
D. Address-of operator
Answer: A
596 What is a dangling pointer?
Options:
A. A pointer that points to a memory location that has been freed
B. A pointer that points to a valid memory location
C. A pointer that is not initialized
D. A pointer that is NULL
Answer: A
597 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
int *p = &x;
printf("%d", *(p + 1));
return 0;
}
Options:
A. 0
B. 5
C. Garbage value
D. Compile Error
Answer: C
598 Which operator is used to compare two pointers?
Options:
A. == and !=
B. > and <
C. >= and <=
D. All of the above
Answer: A
599 What will be the output of the following code?
#include <stdio.h>
int main() {
int numbers[] = {1, 2, 3, 4, 5};
int *ptr = numbers;
printf("%d", *(ptr + 3));
return 0;
}
Options:
A. 1
B. 2
C. 3
D. 4
Answer: D
600 What is the primary purpose of using pointers in C?
Options:
A. To increase the execution speed of programs
B. To allow dynamic memory allocation and deallocation
C. To simplify complex mathematical operations
D. To provide a way to access and manipulate memory directly
Answer: D
Pointers: Pointer arithmetic
601 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {5, 10, 15};
int *ptr = arr;
printf("%d", *(ptr + 1));
return 0;
}
Options:
A. 5
B. 10
C. 15
D. Address of arr
Answer: B
602 How is an array name in C interpreted?
Options:
A. As a constant pointer to its first element
B. As a pointer to its last element
C. As a variable storing the size of the array
D. As a function that returns its elements
Answer: A
603 What does arr == &arr[0] evaluate to?
Options:
A. True
B. False
C. Error
D. Undefined
Answer: A
604 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
printf("%d", *arr + 2);
return 0;
}
Options:
A. 3
B. 4
C. 5
D. 6
Answer: A
605 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
printf("%d", *(arr + 2));
return 0;
}
Options:
A. 1
B. 2
C. 3
D. Address of arr
Answer: C
606 Which of the following correctly assigns a pointer to the first element of an
array?
Options:
A. int *p = arr[0];
B. int *p = &arr;
C. int *p = arr;
D. int *p = &arr[0];
Answer: D
607 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {10, 20, 30};
int *ptr = arr;
printf("%d", *(ptr++));
return 0;
}
Options:
A. 10
B. 20
C. 30
D. Address of arr
Answer: A
608 How are arrays passed to functions in C?
Options:
A. By value
B. By reference
C. As a copy of the entire array
D. As a pointer to the first element
Answer: D
609 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {5, 10, 15};
printf("%d", arr);
return 0;
}
Options:
A. 5
B. 10
C. 15
D. Address of arr
Answer: D
610 What does the expression arr + 2 point to?
Options:
A. The second element of the array
B. The third element of the array
C. The address of the second element
D. The address of the third element
Answer: B
611 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {2, 4, 6, 8};
printf("%d", *(arr + 2) + 1);
return 0;
}
Options:
A. 3
B. 5
C. 7
D. 9
Answer: C
612 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d", *(arr + 4) - *(arr + 1));
return 0;
}
Options:
A. 1
B. 2
C. 3
D. 4
Answer: C
613 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {5, 10, 15, 20};
int *ptr = arr;
printf("%d", *(ptr + 3));
return 0;
}
Options:
A. 5
B. 10
C. 15
D. 20
Answer: D
614 How can you determine the number of elements in an array using pointers?
Options:
A. Using sizeof operator
B. By subtracting the base address from the end address
C. By counting elements until a sentinel value
D. Both A and B
Answer: D
615 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4};
int *ptr = arr;
printf("%d", *ptr++);
printf("%d", *ptr);
return 0;
}
Options:
A. 12
B. 21
C. 13
D. 22
Answer: A
616 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", *arr + 3);
return 0;
}
Options:
A. 1
B. 3
C. 4
D. 6
Answer: C
617 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", *(arr + 1) + 3);
return 0;
}
Options:
A. 3
B. 5
C. 6
D. 7
Answer: B
618 What does the expression &arr return?
Options:
A. Address of the first element
B. Address of the last element
C. Address of the entire array
D. None of the above
Answer: A
619 What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[3] = {5, 10, 15};
int *ptr = arr;
printf("%d", *(++ptr));
return 0;
}
Options:
A. 5
B. 10
C. 15
D. Address of arr
Answer: B
620 How is the memory allocated for arrays in C?
Options:
A. Contiguously
B. Randomly
C. Dynamically
D. Indirectly
Answer: A
Pointers and Strings
621 What will be the output of the following code?
#include <stdio.h>
int main() {
char *str = "Hello";
printf("%c", *(str + 1));
return 0;
}
Options:
A. H
B. e
C. l
D. o
Answer: B
622 How is a string represented in C?
Options:
A. Array of characters
B. Pointer to a character
C. Structure
D. Integer array
Answer: A
623 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "World";
printf("%c", *str);
return 0;
}
Options:
A. W
B. o
C. r
D. l
Answer: A
624 What will be the output of the following code?
#include <stdio.h>
int main() {
char *str = "Pointer";
printf("%s", str + 2);
return 0;
}
Options:
A. Pointer
B. nter
C. inter
D. Inter
Answer: C
625 How can you determine the length of a string using pointers?
Options:
A. Using strlen() function
B. By incrementing a pointer until the null character
C. By using the sizeof() operator
D. Both A and B
Answer: B
626 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Pointer";
printf("%c", *(str + 5));
return 0;
}
Options:
A. e
B. r
C. o
D. t
Answer: A
627 What does the expression *(str++) do?
Options:
A. Increments the string pointer
B. Decrements the string pointer
C. Dereferences the string pointer and then increments it
D. Increments the string pointer and then dereferences it
Answer: C
628 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Hello";
printf("%s", str++);
return 0;
}
Options:
A. Hello
B. ello
C. llo
D. Error
Answer: D
629 What will be the output of the following code?
#include <stdio.h>
int main() {
char *ptr = "String";
printf("%c", *(ptr + 3));
return 0;
}
Options:
A. S
B. t
C. i
D. n
Answer: C
630 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Computer";
printf("%s", str + 3);
return 0;
}
Options:
A. Com
B. puter
C. put
D. mputer
Answer: B
631 What will be the output of the following code?
#include <stdio.h>
int main() {
char *str = "C Language";
printf("%s", str + 2);
return 0;
}
Options:
A. C Language
B. Language
C. nguage
D. Language
Answer: B
632 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Programming";
printf("%c", *str + 2);
return 0;
}
Options:
A. R
B. r
C. o
D. g
Answer: A
633 What does the expression str[3] access in a string "Pointer"?
Options:
A. First character
B. Third character
C. Fourth character
D. Fifth character
Answer: D
634 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Programming";
printf("%s", str + 4);
return 0;
}
Options:
A. Pro
B. amming
C. ramming
D. gramming
Answer: C
635 What will be the output of the following code?
#include <stdio.h>
int main() {
char *str = "C Programming";
printf("%c", *(str + 7));
return 0;
}
Options:
A. C
B. P
C. a
D. r
Answer: C
636 How can you determine the length of a string using pointer arithmetic?
Options:
A. By counting the number of characters
B. By using the strlen() function
C. By incrementing a pointer until the null character
D. By using the sizeof() operator
Answer: C
637 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Pointers";
printf("%s", str + 1);
return 0;
}
Options:
A. Pointers
B. ointers
C. inter
D. inters
Answer: B
638 What will be the output of the following code?
#include <stdio.h>
int main() {
char *str = "Strings";
printf("%c", *(str + 5));
return 0;
}
Options:
A. S
B. g
C. i
D. n
Answer: B
639 What will be the output of the following code?
#include <stdio.h>
int main() {
char str[] = "Hello";
printf("%c", *(str + 4));
return 0;
}
Options:
A. H
B. e
C. l
D. o
Answer: D
640 What does the expression *(str--) do?
Options:
A. Decrements the string pointer
B. Increments the string pointer
C. Dereferences the string pointer and then decrements it
D. Dereferences the string pointer and then increments it
Answer: C
Pointers and functions
641 What will be the output of the following code?
#include <stdio.h>
void display(int *ptr) {
printf("%d", *ptr);
}
int main() {
int x = 5;
display(&x);
return 0;
}
Options:
A. 0
B. 5
C. Garbage value
D. Compilation error
Answer: B
642 What does a function prototype with a pointer argument allow?
Options:
A. Passing the address of the variable
B. Passing the value of the variable
C. Passing multiple variables
D. Returning a pointer value
Answer: A
643 What will be the output of the following code?
#include <stdio.h>
void modify(int *p) {
*p = *p * *p;
}
int main() {
int num = 3;
modify(&num);
printf("%d", num);
return 0;
}
Options:
A. 3
B. 6
C. 9
D. 12
Answer: C
644 How are pointers used in functions?
Options:
A. To return multiple values
B. To pass values by reference
C. To allocate memory dynamically
D. To perform arithmetic operations
Answer: B
645 What will be the output of the following code?
#include <stdio.h>
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int x = 5, y = 10;
swap(&x, &y);
printf("%d %d", x, y);
return 0;
}
Options:
A. 5 10
B. 10 5
C. 0 0
D. Compilation error
Answer: B
646 What will be the output of the following code?
#include <stdio.h>
void add(int *a, int *b) {
*a += *b;
}
int main() {
int num1 = 5, num2 = 3;
add(&num1, &num2);
printf("%d", num1);
return 0;
}
Options:
A. 3
B. 5
C. 8
D. 15
Answer: C
647 What is the purpose of using pointers in function parameters?
Options:
A. To pass the value of a variable
B. To pass a reference to a variable
C. To return multiple values from a function
D. To allocate memory for local variables
Answer: B
648 What will be the output of the following code?
#include <stdio.h>
void change(char *str) {
*str = 'A';
}
int main() {
char ch = 'B';
change(&ch);
printf("%c", ch);
return 0;
}
Options:
A. A
B. B
C. Compilation error
D. Runtime error
Answer: A
649 What will be the output of the following code?
#include <stdio.h>
void compute(int *x, int *y) {
*x += *y;
*y = *x - *y;
}
int main() {
int a = 10, b = 5;
compute(&a, &b);
printf("%d %d", a, b);
return 0;
}
Options:
A. 15 10
B. 15 5
C. 10 15
D. 5 10
Answer: A
650 What will be the output of the following code?
#include <stdio.h>
void update(int *p) {
int var = 7;
p = &var;
}
int main() {
int num = 5;
update(&num);
printf("%d", num);
return 0;
}
Options:
A. 5
B. 7
C. Compilation error
D. Runtime error
Answer: A
651 What will be the output of the following code?
#include <stdio.h>
void func(int **p) {
int q = 10;
*p = &q;
}
int main() {
int x = 5;
int *ptr = &x;
func(&ptr);
printf("%d", *ptr);
return 0;
}
Options:
A. 5
B. 0
C. Compilation error
D. Runtime error
Answer: B
652 How can a function modify the value of a variable passed as an argument?
Options:
A. By passing the variable by value
B. By using a global variable
C. By passing the variable by reference using a pointer
D. By using a local variable in the function
Answer: C
653 What will be the output of the following code?
#include <stdio.h>
void modify(int *p) {
*p = *p + 10;
}
int main() {
int num = 5;
modify(&num);
printf("%d", num);
return 0;
}
Options:
A. 5
B. 10
C. 15
D. 20
Answer: C
654 What will be the output of the following code?
#include <stdio.h>
void change(int *ptr) {
int num = 15;
ptr = #
}
int main() {
int val = 5;
int *p = &val;
change(p);
printf("%d", *p);
return 0;
}
Options:
A. 5
B. 15
C. Compilation error
D. Runtime error
Answer: A
655 What will be the output of the following code?
#include <stdio.h>
void modify(int *ptr) {
int val = 8;
ptr = &val;
}
int main() {
int num = 4;
int *p = #
modify(p);
printf("%d", *p);
return 0;
}
Options:
A. 4
B. 8
C. Compilation error
D. Runtime error
Answer: A
656 How can a function return multiple values in C?
Options:
A. Using an array
B. Using a structure
C. Using pointers
D. Using global variables
Answer: B
657 What will be the output of the following code?
#include <stdio.h>
void modify(int **pp) {
int temp = 20;
*pp = &temp;
}
int main() {
int x = 10;
int *ptr = &x;
modify(&ptr);
printf("%d", *ptr);
return 0;
}
Options:
A. 10
B. 0
C. Compilation error
D. Runtime error
Answer: B
658 What does the following function declaration indicate?
void (*func_ptr)(int);
Options:
A. A pointer to an integer
B. A function that takes an integer pointer as an argument
C. A pointer to a function that takes an integer as an argument
D. A function that returns an integer pointer
Answer: C
659 What is the purpose of using function pointers in C?
Options:
A. To pass functions as arguments to other functions
B. To return multiple values from a function
C. To reduce the number of function calls
D. To perform arithmetic operations on functions
Answer: A
660 What will be the output of the following code?
#include <stdio.h>
void modifyArray(int arr[]) {
arr[0] = 5;
}
int main() {
int values[] = {1, 2, 3};
modifyArray(values);
printf("%d", values[0]);
return 0;
}
Options:
A. 1
B. 2
C. 3
D. 5
Answer: D
Structures and Unions
661 What will be the output of the following code?
#include <stdio.h>
struct Sample {
int x;
};
int main() {
struct Sample s;
s.x = 10;
printf("%d", s.x);
return 0;
}
Options:
A. 0
B. 1
C. 10
D. Garbage Value
Answer: C
662 Which keyword is used to define a union in C?
Options:
A. struct
B. typedef
C. union
D. enum
Answer: C
663 What is the size of a union?
Options:
A. Sum of sizes of its members
B. Maximum size of its members
C. Minimum size of its members
D. Average size of its members
Answer: B
664 What will be the output of the following code?
#include <stdio.h>
union Data {
int i;
float f;
};
int main() {
union Data d;
d.i = 10;
printf("%f", d.f);
return 0;
}
Options:
A. 0.000000
B. 10.000000
C. Garbage Value
D. Compilation Error
Answer: A
665 Can a union contain functions as members?
Options:
A. Yes
B. No
C. Only static functions
D. Only inline functions
Answer: B
666 What will be the output of the following code?
#include <stdio.h>
struct Book {
int pages;
float price;
};
int main() {
struct Book b = {300, 25.50};
printf("%d", b.pages);
return 0;
}
Options:
A. 25.50
B. 300
C. 3002550
D. Compilation Error
Answer: B
667 What is the primary difference between a structure and a union?
Options:
A. Structures are used for representing hierarchical data, while unions are
used for saving memory.
B. Structures and unions are identical in functionality.
C. Structures cannot have methods, while unions can.
D. Unions are used for representing hierarchical data, while structures are
used for saving memory.
Answer: A
668 What will be the output of the following code?
#include <stdio.h>
union Sample {
int x;
float y;
};
int main() {
union Sample s;
s.x = 10;
s.y = 20.5;
printf("%d %f", s.x, s.y);
return 0;
}
Options:
A. 10 20.500000
B. 20 20.500000
C. 10 10.000000
D. 1101266944 20.500000
Answer: D
669 Which of the following statements is true about unions?
Options:
A. All members of a union are accessed simultaneously.
B. Only one member of a union can be accessed at a time.
C. A union can contain members of different types without any restriction.
D. Unions can be nested within structures.
Answer: B
670 What will be the output of the following code?
#include <stdio.h>
union Data {
int i;
char c;
};
int main() {
union Data d;
d.i = 65;
printf("%c", d.c);
return 0;
}
Options:
A. A
B. 65
C. 0
D. Compilation Error
Answer: A
671 Which of the following is true about structures in C?
Options:
A. Structures can contain members of different types.
B. Structures can only contain members of the same type.
C. Structures cannot be passed to functions.
D. Structures can contain functions as members.
Answer: A
672 What will be the output of the following code?
#include <stdio.h>
union U {
int x;
char y;
};
int main() {
union U u;
u.y = 'A';
printf("%d", u.x);
return 0;
}
Options:
A. 65
B. A
C. 0
D. 1
Answer: A
673 Which of the following is true about the memory allocation of structures and
unions?
Options:
A. Structures allocate memory for all members separately.
B. Unions allocate memory for all members separately.
C. Structures allocate memory only for the largest member.
D. Unions allocate memory for all members simultaneously.
Answer: C
674 What will be the output of the following code?
#include <stdio.h>
union Example {
int x;
char y;
};
int main() {
union Example e;
e.x = 97;
printf("%c", e.y);
return 0;
}
Options:
A. a
B. 97
C. 0
D. Compilation Error
Answer: A
675 Which operator is used to access members of a structure through a pointer in
C?
Options:
A. * (asterisk)
B. . (dot)
C. -> (arrow)
D. : (colon)
Answer: C
676 What will be the output of the following code?
#include <stdio.h>
union Test {
int x;
float y;
};
int main() {
union Test t;
t.y = 10.5;
printf("%d", t.x);
return 0;
}
Options:
A. 10
B. 11
C. some value depending on the system
D. Compilation Error
Answer: C
677 Which of the following best describes a union?
Options:
A. A data structure that contains variables of different types.
B. A data structure that can contain multiple variables simultaneously.
C. A data structure that allocates memory for all members separately.
D. A data structure that is similar to an array.
Answer: B
678 What will be the output of the following code?
#include <stdio.h>
struct Book {
int pages;
float price;
};
int main() {
struct Book b;
b.pages = 500;
printf("%f", b.price);
return 0;
}
Options:
A. 0.000000
B. 500.000000
C. Garbage Value
D. Compilation Error
Answer: A
679 Which of the following best describes a structure in C?
Options:
A. A data type that can only hold a single value.
B. A composite data type that can hold multiple values of different types.
C. A data type that represents a sequence of elements of the same type.
D. A data type that can be used to represent complex numbers.
Answer: B
680 What is the keyword used to create an instance of a structure or union in C?
Options:
A. create
B. new
C. struct/union
D. instance
Answer: C
Dynamic Memory Allocation
681 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
*ptr = 5;
free(ptr);
printf("%d", *ptr);
return 0;
}
Options:
A. 5
B. 0
C. Garbage Value
D. Compilation Error
Answer: B
682 Which function is used to allocate memory dynamically in C?
Options:
A. calloc()
B. malloc()
C. realloc()
D. All of the above
Answer: D
683 Which of the following is not a benefit of dynamic memory allocation?
Options:
A. Flexibility in memory management
B. Efficient use of memory
C. Automatic garbage collection
D. Better memory utilization
Answer: C
684 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = NULL;
printf("%d", *ptr);
return 0;
}
Options:
A. 0
B. Garbage Value
C. Compilation Error
D. Segmentation Fault
Answer: D
685 Which function is used to release memory allocated by malloc()?
Options:
A. free()
B. release()
C. deallocate()
D. remove()
Answer: A
686 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(3 * sizeof(int));
ptr[0] = 1;
ptr[1] = 2;
printf("%d", ptr[2]);
free(ptr);
return 0;
}
Options:
A. 0
B. Garbage Value
C. 1
D. Compilation Error
Answer: B
687 Which function is used to change the size of the dynamically allocated
memory block?
Options:
A. malloc()
B. calloc()
C. realloc()
D. resize()
Answer: C
688 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
*ptr = 7;
ptr = (int *)malloc(sizeof(int));
printf("%d", *ptr);
return 0;
}
Options:
A. 7
B. 0
C. Garbage Value
D. Compilation Error
Answer: B
689 Which of the following functions initializes the allocated memory with zeros?
Options:
A. malloc()
B. realloc()
C. calloc()
D. initmalloc()
Answer: C
690 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)calloc(5, sizeof(int));
printf("%d", ptr[2]);
free(ptr);
return 0;
}
Options:
A. 0
B. 1
C. Garbage Value
D. Compilation Error
Answer: A
691 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
*ptr = 3;
ptr = NULL;
printf("%d", *ptr);
return 0;
}
Options:
A. 3
B. 0
C. Garbage Value
D. Compilation Error
Answer: D
692 Which function is used to allocate memory for an array of elements initialized
to 0?
Options:
A. alloc()
B. calloc()
C. malloc_zero()
D. create()
Answer: B
693 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(2 * sizeof(int));
*ptr = 5;
*(ptr + 1) = 10;
printf("%d", ptr[1]);
return 0;
}
Options:
A. 5
B. 10
C. 0
D. Compilation Error
Answer: B
694 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
printf("%d", *ptr);
return 0;
}
Options:
A. 0
B. Garbage Value
C. 1
D. Compilation Error
Answer: B
695 Which function is used to deallocate memory in C?
Options:
A. delete()
B. free()
C. deallocate()
D. remove()
Answer: B
696 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(3 * sizeof(int));
printf("%d", *ptr);
free(ptr);
printf("%d", *ptr);
return 0;
}
Options:
A. 0, 0
B. 0, Garbage Value
C. Garbage Value, Garbage Value
D. Compilation Error
Answer: C
697 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
ptr = (int *)realloc(ptr, 2 * sizeof(int));
printf("%d", sizeof(ptr) / sizeof(int));
free(ptr);
return 0;
}
Options:
A. 1
B. 2
C. Garbage Value
D. Compilation Error
Answer: B
698 Which function is used to allocate memory without initializing it?
Options:
A. malloc()
B. calloc()
C. realloc()
D. initmalloc()
Answer: A
699 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(2 * sizeof(int));
ptr[0] = 1;
ptr[1] = 2;
ptr = (int *)realloc(ptr, 3 * sizeof(int));
printf("%d", ptr[2]);
free(ptr);
return 0;
}
Options:
A. 0
B. 1
C. 2
D. Garbage Value
Answer: A
700 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(sizeof(int));
*ptr = 15;
free(ptr);
printf("%d", *ptr);
return 0;
}
Options:
A. 15
B. 0
C. Garbage Value
D. Compilation Error
Answer: C
701 Which function is used to allocate memory for an array of elements without
initializing them?
Options:
A. alloc()
B. calloc()
C. malloc()
D. initmalloc()
Answer: C
702 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)calloc(2, sizeof(int));
ptr[1] = 7;
printf("%d", *ptr);
free(ptr);
return 0;
}
Options:
A. 0
B. 7
C. Garbage Value
D. Compilation Error
Answer: A
703 Which function should be used to reallocate memory in C when the
previously allocated memory is insufficient?
Options:
A. realloc()
B. resize()
C. adjust()
D. extend()
Answer: A
704 What will be the output of the following code?
#include <stdio.h>
#include <stdlib.h>
int main() {
int *ptr = (int *)malloc(2 * sizeof(int));
ptr[0] = 3;
ptr[1] = 6;
ptr = (int *)realloc(ptr, 1 * sizeof(int));
printf("%d", ptr[0]);
free(ptr);
return 0;
}
Options:
A. 3
B. 6
C. Garbage Value
D. Compilation Error
Answer: A
Preprocessor Directives -> #define, #include
705 What will be the output of the following code?
#include <stdio.h>
#define NUM 5
int main() {
printf("%d", NUM * 2);
return 0;
}
Options:
A. 10
B. 5
C. 52
D. Compilation Error
Answer: A
706 Which directive is used to include a file in C?
Options:
A. #import
B. #define
C. #include
D. #attach
Answer: C
707 What will be the output of the following code?
#include <stdio.h>
#define SQUARE(x) x * x
int main() {
int num = 4;
printf("%d", SQUARE(num + 2));
return 0;
}
Options:
A. 16
B. 36
C. 14
D. Compilation Error
Answer: C
708 Which directive is used to define a macro in C?
Options:
A. #macro
B. #define
C. #macrodefine
D. #makro
Answer: B
709 What will be the output of the following code?
#include <stdio.h>
#define VALUE 10 + 5
int main() {
printf("%d", VALUE * 2);
return 0;
}
Options:
A. 30
B. 20
C. 25
D. Compilation Error
Answer: B
710 Which directive is used to include a user-defined header file?
Options:
A. #include <filename>
B. #import "filename"
C. #define "filename"
D. #attach <filename>
Answer: A
711 What will be the output of the following code?
#include <stdio.h>
#define MAX(a, b) a > b ? a : b
int main() {
printf("%d", MAX(3, 2) + MAX(4, 1));
return 0;
}
Options:
A. 7
B. 6
C. 3
D. Compilation Error
Answer: C
712 What will be the output of the following code?
#include <stdio.h>
#define MESSAGE "Hello, World!"
int main() {
printf("%s", MESSAGE);
return 0;
}
Options:
A. Hello, World!
B. MESSAGE
C. "Hello, World!"
D. Compilation Error
Answer: A
713 Which directive is used to include a standard library header file?
Options:
A. #include "filename"
B. #import <filename>
C. #include <filename>
D. #define <filename>
Answer: C
714 What will be the output of the following code?
#include <stdio.h>
#define PRODUCT(x, y) x * y
int main() {
printf("%d", PRODUCT(3 + 2, 4 + 1));
return 0;
}
Options:
A. 20
B. 12
C. 15
D. Compilation Error
Answer: B
715 Which directive is used to define a constant in C?
Options:
A. #const
B. #define
C. #constant
D. #var
Answer: B
716 What will be the output of the following code?
#include <stdio.h>
#define AREA(l, w) l * w
int main() {
int length = 4;
int width = 3;
printf("%d", AREA(length + 1, width + 1));
return 0;
}
Options:
A. 12
B. 8
C. 15
D. Compilation Error
Answer: B
717 Which directive is used to conditionally include code?
Options:
A. #if
B. #include
C. #define
D. #ifdef
Answer: A
718 What will be the output of the following code?
#include <stdio.h>
#define VALUE 5 + 3 * 2
int main() {
printf("%d", VALUE * 2);
return 0;
}
Options:
A. 17
B. 32
C. 16
D. Compilation Error
Answer: A
719 Which directive is used to define a string in C?
Options:
A. #str
B. #string
C. #s
D. #define
Answer: D
720 What will be the output of the following code?
#include <stdio.h>
#define SUM(a, b) a + b
int main() {
int num1 = 5, num2 = 3;
printf("%d", SUM(num1, num2) * 2);
return 0;
}
Options:
A. 11
B. 26
C. 15
D. Compilation Error
Answer: A
721 Which directive is used to check if a macro is defined?
Options:
A. #ifdefined
B. #ifdef
C. #define
D. #check
Answer: B
722 What will be the output of the following code?
#include <stdio.h>
#define DOUBLE(x) x + x
int main() {
int value = 3;
printf("%d", DOUBLE(value) + DOUBLE(value));
return 0;
}
Options:
A. 12
B. 18
C. 24
D. Compilation Error
Answer: A
723 Which directive is used to undefine a macro?
Options:
A. #undefine
B. #undef
C. #remove
D. #undeclare
Answer: B
724 What will be the output of the following code?
#include <stdio.h>
#define A 2
#define B A*A
int main() {
printf("%d", B * B);
return 0;
}
Options:
A. 8
B. 16
C. 4
D. Compilation Error
Answer: B
725 Which directive is used to replace a macro with another macro?
Options:
A. #replace
B. #rename
C. #define
D. #macro
Answer: C
726 What will be the output of the following code?
#include <stdio.h>
#define CUBE(x) x * x * x
int main() {
int val = 3;
printf("%d", CUBE(val + 1));
return 0;
}
Options:
A. 27
B. 10
C. 125
D. Compilation Error
Answer: B
727 Which directive is used to concatenate two tokens?
Options:
A. #concat
B. ##
C. #merge
D. #link
Answer: B
728 What will be the output of the following code?
#include <stdio.h>
#define VALUE 4 * 4
int main() {
printf("%d", VALUE * VALUE);
return 0;
}
Options:
A. 256
B. 128
C. 32
D. Compilation Error
Answer: A
729 Which directive is used to conditionally include a file based on whether a
macro is defined?
Options:
A. #include <filename>
B. #define
C. #if defined
D. #attach
Answer: C
730 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", printf("Hello"));
return 0;
}
Options:
A. Hello5
B. 5Hello
C. Hello
D. Compilation Error
Answer: A
731 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%c", 65);
return 0;
}
Options:
A. A
B. 65
C. 6
D. Compilation Error
Answer: A
732 What will be the output of the following code?
#include <stdio.h>
int main() {
int num = 123;
printf("%d %d %d", num++, num++, num++);
return 0;
}
Options:
A. 123 124 125
B. 125 124 123
C. 123 125 124
D. Compilation Error
Answer: B
733 What will be the output of the following code?
#include <stdio.h>
int main() {
char ch = 'A';
printf("%d", ch);
return 0;
}
Options:
A. 65
B. A
C. 41
D. Compilation Error
Answer: A
734 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("%d%d", x, y);
return 0;
}
Options:
A. 510
B. 15
C. 5 10
D. Compilation Error
Answer: A
735 What will be the output of the following code?
#include <stdio.h>
int main() {
float num = 123.456;
printf("%.2f", num);
return 0;
}
Options:
A. 123.456
B. 123.45
C. 123
D. Compilation Error
Answer: B
736 What will be the output of the following code?
#include <stdio.h>
int main() {
int a = 5;
printf("%d%d%d", a++, ++a, a);
return 0;
}
Options:
A. 677
B. 657
C. 577
D. Compilation Error
Answer: A
737 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%x", 255);
return 0;
}
Options:
A. ff
B. 255
C. 100
D. Compilation Error
Answer: A
738 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++);
printf("%d", x);
return 0;
}
Options:
A. 56
B. 55
C. 65
D. Compilation Error
Answer: A
739 What will be the output of the following code?
#include <stdio.h>
int main() {
char ch = 'A';
printf("%c", ch + 32);
return 0;
}
Options:
A. A
B. a
C. 97
D. Compilation Error
Answer: B
740 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 10, y = 20;
printf("%d %d", x, y);
return 0;
}
Options:
A. 10 20
B. 20 10
C. 1020
D. Compilation Error
Answer: A
741 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", printf("Hello\n") + printf("World\n"));
return 0;
}
Options:
A. Hello
World
12
B. Hello
World
5
C. 11
D. Compilation Error
Answer: A
742 What will be the output of the following code?
#include <stdio.h>
int main() {
int a = 2, b = 5;
printf("%d", a+++b);
return 0;
}
Options:
A. 7
B. 6
C. 27
D. Compilation Error
Answer: A
743 What will be the output of the following code?
#include <stdio.h>
int main() {
float x = 123.4567;
printf("%.2f", x);
return 0;
}
Options:
A. 123
B. 123.4
C. 123.45
D. 123.46
Answer: D
744 What will be the output of the following code?
#include <stdio.h>
int main() {
char ch = 'A';
printf("%c", ch + 32);
return 0;
}
Options:
A. A
B. a
C. 97
D. Compilation Error
Answer: B
745 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%d", 9 / 2);
return 0;
}
Options:
A. 4.5
B. 4
C. 5
D. Compilation Error
Answer: B
746 What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 10;
printf("%d %d", ++x, x++);
return 0;
}
Options:
A. 11 11
B. 11 12
C. 12 10
D. Compilation Error
Answer: C
747 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%s", "Hello" "World");
return 0;
}
Options:
A. HelloWorld
B. Hello World
C. HelloWorld!
D. Compilation Error
Answer: A
748 What will be the output of the following code?
#include <stdio.h>
int main() {
printf("%s", "Hello" " ");
printf("%s", "World");
return 0;
}
Options:
A. Hello World
B. HelloWorld
C. Hello World!
D. Compilation Error
Answer: A