PRAVARTAN’25
Code ArenA
Name: Email:
Mobile no: College:
Multiple Choice Questions
1.What is the correct syntax for a for loop in C?
a) for (int i = 0; i < 10; i++)
b) for i = 0; i < 10; i++
c) for (i = 0: i < 10: i++)
d) for (int i=0,i < 10, i++)
2.Find the output of the code
#include <stdio.h>
int main()
{
int a=6;
printf(“%d”,++a);
return 0;
}
a) 4
b) 6
c) 7
d) 5
3. Find the output of the code
#include <stdio.h>
int main()
{
int x = 10;
x += 5;
x *= 2;
printf(“%d”,x);
return 0;
}
a) 20
1
b) 15
c) 10
d) 30
4. Find the output of the code
#include <stdio.h>
int main()
{
int i = 0;
for (i = 0; i <= 3; i++)
printf("%d", i);
return 0;
}
a) 0123
b) 123
c) 012
d) 0
5. Which of the following is not true about C arrays?
a) Arrays are zero-indexed.
b) The size of an array must be known at compile time.
c) Arrays can hold data of different types.
d) The size of an array is fixed once it is declared.
6. Find the output of the code
#include <stdio.h>
int main() {
int x = 5;
printf("%d %d %d", x++, x++, x++);
return 0;
}
a)5 6 7
b)7 6 5
c)Undefined behaviour
d)Compiler Error
7. Which header file is needed for dynamic memory allocation functions?
a) stdlib.h
2
b) stdio.h
c) malloc.h
d) memory.h
8. What is the correct way to declare a pointer to an integer?
a) int ptr;
b) int *ptr;
c) *int ptr;
d) ptr int;
9. Which operator is used for logical AND?
a) &
b) |
c) &&
d) ||
10. What is the purpose of the volatile keyword?
a) To indicate that a variable's value may change unexpectedly.
b) To define a constant variable.
c) To allocate dynamic memory.
d) To declare a function as static.
11. What is the scope of a local variable?
a) Throughout the program
b) Within the file
c) Within the block it is declared
d) All of the above
12. Find the output of the code
#include <stdio.h>
int main() {
int a = 5;
printf("%d", a << 2);
return 0;
}
a) 5
b) 10
c) 20
3
d) 25
13. What is the purpose of the fclose() function?
a) To open a file.
b) To close a file.
c) To close a function.
d) To write data to a file.
14. Which of the following is true for variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
15. What is short int in C programming?
a) The basic data type of C
b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the above
16. Find the output of the code
#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("PRAVARTAN ‘25! %d\n", y);
return 0;
}
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value
17. The format identifier ‘%i’ is also used for _____ data type.
a) char
b) int
4
c) float
d) double
18. Find the output of the code
#include<stdio.h>
int main() {
char c = 'A';
printf("%d", c);
return 0;
}
a) 65
b) A
c)Syntax Error
d)None of these
19. Find the output of the code
#include<stdio.h>
int main() {
printf("%d", 500);
return 0;
}
a) 500
b) %d
c) Syntax Error
d) None of these
20. Which operator has higher precedence, '+' or '*'?
a) *
b) Both are same
c) =+
d)None
21. What is the purpose of the ‘sizeof’ operator in C?
A. Calculate square root
B. Determine size
C. Increase the size of variable
5
D. Convert to string
22. Find the output of the code
#include<stdio.h>
int main()
{
int i=4, j=-1, k=0, w, x, y, z;
w = i || j || k;
x = i && j && k;
y = i || j &&k;
z = i && j || k;
printf("%d, %d, %d, %d\n", w, x, y, z);
return 0;
}
a) 1, 1, 1, 1
b) 1, 1, 0, 1
c) 1, 0, 0, 1
d) 1, 0, 1, 1
23. Which of the following special symbol allowed in a variable name?
a) *
b) |
c) -
d) _
24. Find the output of the code
#include<stdio.h>
#include<string.h>
int main()
{
printf("%d\n", strlen("123456"));
return 0;
}
a) 6
b) 12
c) 7
6
d) Syntax Error
25. What is the limit for number of functions in a C Program?
a) 32
b) 64
c) 128
d) No Limit
26. How many keywords are there in C Language?
a) 30
b) 22
c) 32
d) 36
27. Considering the size of char variables as one byte, what will be the size of the
array declared below?
char array [] = “programming language”;
a) 11 Bytes
b) 8 Bytes
c) 20 Bytes
d) 21 Bytes
28. Find the output of the code
#include <stdio.h>
int main() {
char ch = 'a' + 1;
printf("%c", ch);
return 0;
}
a) a
b) b
c) 98
d) Compilation error
29. Find the output of the code
7
#include <stdio.h>
int main() {
int a = 10, b = 20;
if (a > b);
printf("a is greater");
return 0;
}
a) a is greater
b) No output
c) Compilation error
d) Undefined behaviour
30. Find the output of the code
#include <stdio.h>
int main() {
int arr[] = {5, 10, 15, 20, 25};
printf("%d", *(arr + 2));
return 0;
}
a) 5
b) 10
c) 15
d) Compilation error