4) What Will Be The Output of The Following C Code?: #Include Void Main
4) What Will Be The Output of The Following C Code?: #Include Void Main
#include<stdio.h>
void main() {
int a= 10 + 4.867;
printf("a=%d", a); }
A) a=10
B) a=14.867
C)a=14
D) compiler error
A) 1, 2, 3, 4
B) 2, 3, 4
C) 1, 2, 3
D) 2, 3
A) c=1
B) c=2
C) c=3
D) c=4
#include <stdio.h>
void main()
{
int i = 0, k=0;
if (i == 0)
goto label;
for (;k < 3; k++,i++)
{
printf("hi ");
label:printf("%d", i);
}
}
a) 0 b) hi hi hi 0 1 2
c) 0hi 1hi 2 d) 0 0 0
5)Find the output of the following code:
#include<stdio.h>
int main()
{
float a=15.3;
int b=3;
printf("%d",a%b);
}
E) 3 B)0
C)Error D)None of the above
C)0 D)0
012 2 12
A) 7 5 9 B)7 5 0
C)6 6 9 D)6 6 0
8)
What is the output of the following code?
#include<stdio.h>
int main()
{
int a=0.9;
if(a<0.9)
printf("yes");
else
printf("no");
return 0;
}
#include <stdio.h>
int main(void)
{
int a=92, b=98, c=67;
if (a > b)
{
if (a > c)
{
printf("%d \n",a);
}
else
{
printf("%d \n",c);
}
}
else if (b > c)
{
printf("%d \n",b);
}
else
{
printf("%d \n",c);
}
return 0;
}
A) 92 B) 67
C) 98 D) Compilation Error
10.
Write the output of the following program
#include <stdio.h>
void main()
{
int x=50;
if(x=18)
printf("TRUE");
else
printf("FALSE");
}
A) True B) False
C) Error D) None
C) dowhile(condition) B) do while(condition)
{ {
//statements } //statements }
C) do D) do
{ {
//statements //statements
}while(condition) }while(condition);
15)What will be the output of the following C code?
#include <stdio.h>
int main()
{
printf("%d ", 1);
goto l1;
printf("%d ", 2);
l1:goto l2;
printf("%d ", 3);
l2:printf("%d ", 4);
}
a) 1 4 b) Compilation error
c) 1 2 4 d) 1 3 4
A) 0 B) 30
C) 40 D) 20
17)How many times does “Hi” get printed?
#include <stdio.h>
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i != 1)
continue;
printf("Hi \n");
}
}
}
A)16 B)4
C)20 D)8
#include <stdio.h>
int main()
{
int a = 10;
do
{
printf("%d ", a);
a = a + 1;
}while(a<14);
return 0;
}
A)10 11 12 13 B)11 12 13 14
C)10 11 12 13 14 D)11 12 13 14 15
#include <stdio.h>
int main()
{
int i=1, number=0;
scanf("%d",&number);
do
{
printf("%d ", (number*i));
i++;
}while(i<=5);
return 0;
}
A)1 2 4 6 8 B)2 4 8 16 32
C)2 4 6 8 10 D)1 3 5 7 9
20)Write the output of the following program
#include<stdio.h>
int main()
{
int n;
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}
A) 9 7 5 3 1 B) 9 8 7 6 5 4 3 2 1
C) Infinite loop D) 9 7 5 3
#include <stdio.h>
void main()
{
int i,j,charVal='A';
for(i = 5;i >= 1;i--)
{
for(j=0;j< i;j++)
printf("%c ",(charVal+j));
printf("\n");
}
}
D) A B C D E B) A B C D
A B CD E ABCD
A B CD E ABCD
A B CD E ABCD
ABCDE
C) A B C D D) A B C D E
ABC AB CD
AB ABC
A AB
A
#include <stdio.h>
void main()
{
int i;
for(i=0;i<10;++i)
{
printf("#");
if(i>6)
continue;
printf("%d",i);
}
}
A) #0#1#2#3#4#5#6###
B) #0#1#2#3#4#5#6#7#8#9#10
C) #0#1#2#3#4#5##7#8#9#10
D) #0#1#2#3#4#5#
23)
What is the output of the following code?
#include<stdio.h>
int main()
{
int a=1+2*3%4/5-6;
int b=a>10?100:50;
printf("%d %d",a,b);
}
24)
3) Choose a correct statement about C break; statement.?
A) break; statement can be used inside switch block
B) break; statement can be used with loops like for, while and do while.
C) A single break; statement can force execution control to come out of only one loop.
D) All the above.
25)
How many times does N get printed in the following code?
#include<stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("N");
i++;
if(i==5) break;
}
return 0;
}
A)0 B)8
C)4 D)9
26)
What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
(1)
for( ; ; )
printf("SGC is chill :))");
(2) (3)
#include <stdio.h> #include <stdio.h>
int main() int main()
{ {
int i=0; int i=1;
while(1) while(i<=10);
{ {
i++; printf("%d", i);
printf("i is :%d",i); i++;
} }
return 0; return 0;
} }
Options:
A) Only 1
B) Both 1 and 2
C) All of the above
D) None of the above
28)
#include<stdio.h>
int main()
{
int a=5;
switch(a)
{
case 0: printf("0 ");
break;
case 3: printf("3 ");
break;
case 5: printf("5 ");
break;
default: printf("RABBIT ");
break;
}
a=3;
switch(a)
{
case 0: printf("0 ");
case 3: printf("3 ");
case 5: printf("5 ");
default: printf("RABBIT "); break;
}
return 0;
}
A) 5 RABBIT
B) 5 3
C) 0 3 5 RABBIT RABBIT
D) 5 3 5 RABBIT
29)What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0, k=0;
if (i == 0)
goto label;
for (;k < 3; k++,i++)
{
printf("hi ");
label:printf("%d", i);
}
}
a) 0 b) hi hi hi 0 1 2
c) 0hi 1hi 2 d) 0 0 0