C MCQ Set-8 : Multiple Choice Questions in C Set-8

Set-26 C MCQ

1. What is the output of C Program.?

int myshow(int);
void main()
{
myshow(5);
myshow(10);
}

int myshow(int b)
{
printf(“Received %d, “, b);
}

A) Received 5, Received 10,
B) Received 10, Received 5,
C) Received 0, Received 0,
D) Compiler error

Ans:A


2. What is the output of code given below?

#include <stdio.h>
int main()
{
int i=1;
for(;;)
{
printf(“%d”,i);
if(i=5)
break;
}
}

A)1 2 3 4 5
B)1
C)1 infinite times
D)Compilation error

Ans:B


3. What is the output of code given below?

#include <stdio.h>
int main()
{
int i=1;
for(;i<=10;i++)
{
if(i%2==0)
continue;
printf(“%d”,i);
}
}

A)2 4 6 8 10
B)1 3 5 7 9
C)1 2 3 4 5 6 7 8 9 10
D)Compilation Error

Ans:B


4. What is the output of code given below?

#include <stdio.h>
int main()
{
int i;
int j=1;
for(i=1;i<3;i++)
for(i=1;i<4;i++)
{
if(i==2)break;
printf(“%d%d”,i,j);
}
}

A)1 1
B)1 1 1 2 1 3
c)1 1 infinite times
D)compilation error

Ans:A


5. What is the output of code given below?

#include <stdio.h>
int main()
{
int i,j;
for(i=1;i<3;i++)
for(j=1;j<4;j++)
{
if(i==2)continue;
printf(“%d%d”,i,j);
}
}

A)1 1 1 2 1 3
B)1 1 2 2 3 3
C)No output
D)compilation error

Ans:A


6. What is the output of C Program.?

#include <stdio.h>
int main()
{
int a=3;
while (a==3)
{
printf(“HELLO”);
break;
}
return 0;
}

A) HELLO is printed unlimited number of times
B) HELLO
C) Compiler error
D) None of the above.

Ans:B


7. What is the output of C Program.?

#include <stdio.h>
int main()
{
int k;
for(;;)
{
printf(“HELLO”);
break;
}
return 0;
}

A) HELLO infinite time
B) HELLO
C) Compiler error
D) None of the above

Ans: B


8. What is the output of C Program.?

#include<stdio.h>
int main()
{
int k;
for(printf(“FLOWER “); printf(“YELLOW “); printf(“FRUITS “))
{
break;
}
return 0;
}

A) Compiler error
B) FLOWER FRUITS
C) FLOWER YELLOW
D) FLOWER YELLOW FRUITS

Ans: D


9. What will be the output of following code?

include < stdio.h >
int main()
{
int tally=0;
for(;;)
{
if(tally==10)
break;
printf(“%d “,++tally);
}
return 0;
}

(A)0 1 2 3 4 5 6 7 8 9 10
(B)0 1 2 3 … infinite times
(C)1 2 3 4 5 6 7 8 9 10
(D)1 2 3 4 5 6 7 8 9

Ans:C


10. What will be the output of following code?

include < stdio.h >
int main()
{
for(i=0;i<2;i++);
for(j=i;j<3;j++)
printf(“%d”,j);
}

(A)0 1 2 1 2
(B)2
(C)0 1 2
(D)compilation error

Ans:B


11. What will be the output of following code?

include < stdio.h >
int main()
{
int i, j;
for(i=0;i<3;i++)
for(j=i;j<4;j++)
{
printf(“%d”,j);
break;
}
}

(A)0
(B)0 1 2
(C)0 1 2 3
(D)0 1 2 1 2 3 2 3 3

Ans: B


12. What is the output of C Program with functions.?

#include<stdio.h>
int sum(int,int);
int main()
{
int a=5, b=10, mysum;
mysum = sum(a,b);
printf(“SUM=%d “, mysum);
printf(“SUM=%d”, sum(10,20));
return 0;
}
int sum(int i, int j)
{
return (i+j);
}

A) SUM=15 SUM=30
B) SUM=30 SUM=15
C) SUM=15 SUM=15
D) SUM=30 SUM=30

Ans:A
C MCQ Set-8 Explanation


13. What is the output of C Program with functions.?

int bunny(int,int);
int main()
{
int a, b;
a = bunny(5, 10);
b = bunny(10, 5);
printf(“%d %d”, a, b);
return 0;
}
int bunny(int i, int j)
{
return (i, j);
}

A) 5 10
B) 10 5
C) 5 5
D) Compiler error

Ans:B
C MCQ Set-8 Explanation


14. What is the output of C Program with functions.?

#include <stdio.h>
int fun(int n);
int main()
{
int (ptr)(int ) = fun; (ptr)(3);
return 0;
}

int fun(int n)
{
for(;n > 0; n–)
printf(“PSIT “);
return 0;
}

A)PSIT PSIT PSIT
B)PSIT PSIT
C)Compiler Error
D)Runtime Error

Ans:A


15. What is the output of C Program with functions.?

#include <stdio.h>
int main()
{
void demo();
void (fun)();
fun = demo;
(fun)();
fun();
return 0;
}
void demo()
{
printf(“PSIT “);
}

A)PSIT
B)PSIT PSIT
C)Compiler Error
D)Blank Screen

Ans:B


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *