WorksheetsC Programming (Pre test ET Sec B)
Total questions: 25
Worksheet time: 13mins
Name
Class
Date
1.
Q 1.What is the output of the following code snippet?
#include
main()
{
int const a = 5;
a++;
printf(“%d”,a);
}
a)
5
b)
6
c)
Runtime error
d)
Compile error
2.
Q 2 - What is the output of the following code snippet?
#include
main()
{
const int a = 5;
a++;
printf("%d", a);
}
a)
5
b)
6
c)
Runtime error
d)
Compile error
3.
Q 3 - What is the output of the below code snippet?
#include
main()
{
int a = 5, b = 3, c = 4;
printf("a = %d, b = %d\n", a, b, c);
}
a)
a=5, b=3
b)
a=5, b=3, c=0
c)
a=5, b=3, 0
d)
compile error
4.
Q 4 - Function fopen() with the mode "r+" tries to open the file for __
a)
reading and writing
b)
reading and adding new content
c)
only for reading
d)
it works only for directories
5.
Q 5 - What is the output of the following program?
#include
main()
{
int a[] = {2,1};
printf("%d", *a);
}
a)
0
b)
1
c)
2
d)
Compile error.
6.
Q 6 - What is the output of the following program?
#include
main()
{
int a[3] = {2,,1};
printf("%d", a[a[0]]);
}
a)
0
b)
1
c)
2
d)
Compile error
7.
Q 7 - What is the following program doing?
#include
main()
{
FILE *stream=fopen("a.txt",'r');
}
a)
Trying to open “a.txt” in read mode
b)
Trying to open “a.txt” in write mode.
c)
“stream” is an invalid identifier
d)
Compile error
8.
Q 8 - What is the output of the following program?
#include
main()
{
float t = 2;
switch(t)
{
case 2: printf("Hi");
default: printf("Hello");
}
}
a)
Hi
b)
HiHello
c)
Hello
d)
Error
9.
Q 9 - The type name/reserved word ‘short’ is ___
a)
short long
b)
short char
c)
short float
d)
short int
10.
Q 10 - What is the output of the following program?
#include
void swap(int m, int n)
{
int x = m;
m = n;
n = x; }
main()
{
int x=5, y=3;
swap(x,y);
printf("%d %d", x, y);
}
a)
3 5
b)
5 3
c)
5 5
d)
Compile error
11.
Q 11 - What is the size of ‘int’?
a)
2
b)
4
c)
8
d)
Compiler dependent
12.
Q 12 - What is the output of the following program?
#include
void f()
{
static int i;
++i; printf("%d", i);
}
main()
{
f();
f();
f();
}
a)
1 1 1
b)
0 0 0
c)
3 2 1
d)
1 2 3
13.
Q 13 - Identify the incorrect file opening mode from the following.
a)
r
b)
w
c)
x
d)
a
14.
Q 14 - What is the output of the following code snippet?
#include
main()
{
char c = 'A'+255;
printf("%c", c);
}
a)
A
b)
B
c)
Overflow error at runtime
d)
Compile error
15.
Q 15 - What is the size of the following union definition?
#include
union abc
{
char a,b,c,d,e,f,g,h;
int i;
}abc;
main()
{
printf( "%d", sizeof( abc ));
}
a)
1
b)
2
c)
4
d)
8
16.
Q 16-Ternary operator in C programming is ___.
a)
if-else-if
b)
? :
c)
? ; ?
d)
None of these
17.
Q 17-What will be the output of the following C code?
#include
int main()
{
printf((43 > 43) ? "value 1 is greater!" : "value 1 is not greater!");
return 0;
}
a)
value 1 is not greater
b)
value 1 is greater
c)
Error
d)
None of these
18.
Q 18- When the condition of if statement is false, the flow of code will ___.
a)
go into the if block
b)
Exit the program
c)
Continue the code after skipping the if block
d)
None of these
19.
Q 19-The if-elseif-else statement in C programming is used?
a)
Create multiple conditional statements
b)
Return values
c)
Loop in if-else block
d)
All of these
20.
Q 20-What will be the output of the following C code?
#include
int main()
{
int marks = 43;
if (marks > 90)
printf("Grade : A ");
else if (marks > 75)
printf("Grade : B ");
else if (marks > 60)
printf("Grade : C ");
if (marks > 40)
printf("Grade : D ");
else
printf("Fail ");
return 0;
}
a)
Grade : A
b)
Grade : B
c)
Grade : C
d)
Grade : D
21.
Q21- When all cases are unmatched which case is matched in a switch statement?
a)
Default case
b)
First case
c)
No case
d)
None of these
22.
Q22- Which is the correct format specifier for double type value in C?
a)
%d
b)
%f
c)
%lf
d)
%LF
23.
Q23-What is the correct syntax to declare a variable in C?
a)
data_type variable_name;
b)
data_type as variable_name;
c)
variable_name data_type;
d)
variable_name as data_type;
24.
Q24-Which of these is not a valid parameter passing method in C?
a)
Call by value
b)
Call by reference
c)
Call by pointer
d)
All of these
25.
Q25-A recursive function in C ___.
a)
Call itself again and again
b)
Loop over a parameter
c)
Return multiple values
d)
None of these
100 %
