Reference no: EM13996294
1) What is the output of this C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0; while (i < 2)
{
11: i++;
while (j < 3)
{
printf("loop\n");
goto 11;
}}}
a) Loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop
2) What is the output of this C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (11: i < 2)
{
i++;
while (j < 3)
printf("loop\n");
goto 11;
}}
a) loop loop
b) compile time error
c) loop loop loop loop
d) Infinite loop
3) The output of the code below is(When 1 is entered)
#include <stdio.h>
void main()
{
char *th;
printf("enter a value btw 1 to 3:");
scanf("%s", ch);
switch (th)
{ case 1:
printf ("1");
break.
case 2:
printf("2");
break; }}
a) 1
b) 2
c) Compile time error
d) No Compile time error
4) When 2 is entered, The output of the code below is?
#include <stdio.h>
void main() {
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
printf ("hi");
printf ("hello");
case 1:printf("1\n");
break;
printf("Hi");
default:printf("2\n");
}}
a) 1
b) Hi 2
c) Run time error
d) 2
5) When 1 is entered, The output of the code below is?
#include <stdio.h>
void main() {
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch, ch + 1,ch<=2)
printf("hi");
case 1:print-F("1\ n");break;
case 2:printf("2");break;
}}
a) 1
b) 2
c) 3
d) Run time error
6) What is the output of this C code?
#include <stdio.h>
int main() {
int 1= 0, j = 0;
11: while (i < 2)
{
i++;
while (j < 3) {
printf("loop\n");
goto 11;}}}
a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop
7) What will be the output of the program?
#include<stdio.h>
int main()
{
const int 1=0;
Printf("%d\n", i++);
return 0;
}
a) 0
b) 1
c) error: can't modify constant object
d) Error: ++ needs a value
8) What will be the output of the program?
#include<stdio.h>
#define SQUARE(x) x*x
int main()
{
float s=10, u=30, 1=2, a;
a = 2*(s-u*W tat* attf "Result = %f", a);
return 0;
}
a) Result = -100.000000
b) Result = -25.000000
c) Result = 0.000000
d) Result = 100.000000
.
9) What will be the output of the program?
#include<stdio.h>
int main()
{
unsigned int res;
res= (64 >>(2+1-2)) & (~(1<<2));
printf("%d\n", res);
return 0;
}
a) 32
b) 64
c) 0
d) 128
10) what will be the output of the program?
void main()
{
int 1=2,j=3,k,l;
float a b;
k=i/j*j;
l=j/i*j;
a= i/j*j;
b=j/i*i;
printf("%d %d %f %f" k,l,a,b);
}
a) 3,0,0,0
b) 0,3,0.000000,2.000000
c) 0,0,0,0
d) error
11) what will be the output of the following program?
void main()
{
int a, b;
a=3--25;
b= -3 --(-3);
printf(" %d b= %d", a,b);
}
a) a=22,b=-6
b) a=-6,b=22
c) a=3,b=3
d) error
12) What will be output when you will execute following c code?
Choose all that apply:
#include<stdio.h>
void main(){
int x=-1,y=-1.;
if(++x=++y)
printf("R.I. ponting");
else
printf("C.H. Gayle");
}
a) R.T Ponting
b) C.H. Gayle
c) Warning: x and y are assigned a value that is never used
d) Warning: Condition is always true
e) Compilation error
13) What will be the output of the program?
#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
14) Comment on the following code below
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf("hello");
}
a) It will display hello
b) It will throw an error
c) Nothing will be displayed
d) Compiler dependent
15) The output of the code below is
#include <stdio.h>
void main()
{
int x = 5;
if (x < 1);
printf("Hello");
}
a) compile time error
b) Run time error
c) Hello
d) Varies
16) what is the output of the program?
void main()
{
printf("hai");
}
int main()
{
printf("hello");
return 0;
}
a) Hi
b) Hello
c) Compile time error
d) Nothing
17) The output of the code below is(when 1 is entered)
#include <stdio.h>
void main()
{
double ch;
printf("enter a value btw 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1:printf("1");break;
case 2:printf("2");break;
}
}
a) Compile time error
b) 1
c) 2
d) Varies
18) What is the output of this C code?
#include <stdio.h>
void main()
{
int h = 8;
intb=4*6+3*4<3*4:3;
printf("%d\n", b);
}
a) 3
b) 33
c) 34
d) Run time error
19) What is the output of this C code?
#include <stdio.h>
void main()
{
char a = 'A'; char b = 'B';
int c = a + b %3 - 3 * 2;
printf("%d\n", c);
}
a) 65
b) 58
c) 64
d) 59
20) What is the output of this C code?
#include<stdio.h> int main()
{
printf("%c\n", ~('C'*-1));
return 0;
}
a) A
b) B
c) C
d) D