NEW
Font size
WorksheetsProgramming Skills C/C++
Total questions: 25
Worksheet time: 25mins
A C Variable cannot start with
A- A number
B- A special symbol other than underscore
C- Both A and B
D- An Alphabet
Find the output of the following program-
void main()
{
int i=01289;
printf("%d",i);
}
0289
1289
713
Syntax Error
What is the difference between a declaration and a definition of a variable?
Both can occur multiple times, but a declaration must occur first.
A definition occurs once, but a declaration may occur many times.
Both can occur multiple times, but a definition must occur first.
A declaration occurs once, but a definition may occur many times.
what will be printed by the following code?
void main()
{
short testarray[4][3] = { {1}, {2,3}, {4,5,6}};
printf("%d", sizeof(testarray));
}
Assuming a short is two bytes long.
24
18
12
6
How many times the program will print "SAIT Indore" ?
#include<stdio.h>;
int main()
{
printf("SAIT Indore");
main();
return 0;
}
Infinite times
32767 times
65535 times
Till stack overflows
The value printed by the following program is …………?
void f(int *p, int m)
{
m = m + 5;
p= p + m;
return;
}
void main()
{
int i=10, j=20;
f(&i , j)
printf(“%d”, i+j);
}
50
45
55
60
What would be the output of the following program.
#include<stdio.h>
main()
{
printf(“%d, %d”, sizeof(NULL), sizeof(‘ ‘));
}
2, 1
2, 2
0, 1
0, 2
What will be output if you will compile and execute the following c code?
void main()
{
int i=320;
char ptr=(char )&i;
printf("%d",*ptr);
}
320
1
64
Complier Error
What will be output if you will compile and execute the following c code?
#define x 5+2
void main()
{
int i;
i=x*x*x;
printf("%d", i);
}
343
27
133
Comipler error
What will be output if you will compile and execute the following c code?
void main()
{
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
}
21
18
12
Compiler error
What will be output if you will compile and execute the following c code?
void main()
{
char *str="Hello world";
printf("%d",printf("%s",str));
}
11Hello world
10Hello world
Hello world11
Hello world10
What will be output if you will compile and execute the following c code?
void main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
}
Equal
Less than
Greater than
Compiler error
What will be output if you will compile and execute the following c code?
#include <stdio.h>;
void main()
{
int i=0;
for(;i<=2;)
printf("%d",++i);
}
012
0123
123
Compiler error
What will be output if you will compile and execute the following c code?
void main()
{
int x;
for(x=1;x<=5;x++);
printf("%d",x);
}
4
5
6
Compiler error
What does the following declaration mean?
int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array
What will be output if you will compile and execute the following c code?
void main()
{
double far* p,q;
printf("%d",sizeof(p)+sizeof q);
}
4
8
12
1
#include<stdio.h>
main()
{
int a[3] = {2, ,1};
printf("%d", a[a[0]]);
}
0
1
2
Compile error
What is the output of the following program?
#include<stdio.h>
main()
{
char s[] = "Fine";
*s = 'N';
printf("%s", s);
}
Nine
Fine
Compile error
Runtime error
What is the output of the below code snippet?
#include<stdio.h>
main()
{
for(1;2;3)
printf("Hello");
}
Infinite loop
Prints “Hello” once.
No output
Compile error
What is the output of the following statement?
#include<stdio.h>
main()
{
printf("%d", !0<2);
}
True
False
1
0
What will be output of following c program?
#include<stdio.h>
int main()
{
enum number { a=-1, b= 4,c,d,e};
printf("%d",e);
return 0;
}
5
7
4
Garbage Value
What will be the output of the program?
#include<stdio.h>
#define MAN(x, y) ((x)>(y)) ? (x):(y);
int main()
{
int i=10, j=5, k=0;
k = MAN(++i, j++);
printf("%d, %d, %d\n", i, j, k);
return 0;
}
12, 6, 12
11, 6, 11
11, 5, 11
12, 6, Garbage
Comment on the output of this C code?
#include <stdio.h>
void func();
int main()
{
static int b = 20;
func();
}
void func()
{
static int b;
printf("%d", b);
}
Output will be 0
Output will be 20
Output will be garbage value
Compile time error due to redeclaration of static variable
What is the output of this C code?
#include <stdio.h>
#include <math.h>
void main()
{
int k = sqrt(-4);
printf("%d\n", k);
}
-2
2
Compile time error
None the above
What is the output of this C code?
#include<stdio.h>
void main()
{
register int x;
printf("%d", x);
}
0
1
Compile time error
Junk value
