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

Set-26 C MCQ

1. What will be output of following code?

#include<stdio.h>
int main()
{
int i = 0;
while (i = 0)
printf(“True\n”);
printf(“False\n”);
}

A) True (infinite time)
B) True (1 time) False
C) False
D) Compiler dependent

Ans: C


2. What will be output of following code?

#include<stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 5, j < 10)
{
i++;
j++;
}
printf(“%d, %d\n”, i, j);
}

A) 5, 5
B) 5, 10
C) 10, 10
D) Syntax error

Ans: C


3. What will be output of following code?

#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

Ans: C


4. What will be output of following code?

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

(A)10 5 2 1
(B)10 5 2.5 1.25
(C)compilation error
(D)5 2 1

Ans: A


5. What will be output of following code?

#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
}
while(c–);
printf (“%d\n”, no);
return 0;
}

(A) 1
(B) Runtime Error
(C) 0
(D) Compiler Error

Ans: B


6. What will be output of following code?

#include <stdio.h>
int main()
{
int i=5;
for(;i>=1;)
{
printf(“%d “,i);
continue;
i–;
printf(“%d “,i);
return 0;
}

(A)5 4 4 3 3 2 2 1 1 0
(B)5 4 3 2 1 0
(C)compilation error
(D)5 up to infinite…

Ans: D


7. What is the output of code given below?

# include<stdio.h>
int main()
{
int i=1;
while(++i<=5)
printf(“%d “,i++);
}

A – 1 3 5
B – 2 4
C – 2 4 6
D – 2

Ans:C


8. What is output of below program?

# include<stdio.h>
void main()
{
inti,j,count;
count=0;
for(i=0; i<5; i++);
{
for(j=0;j<5;j++);
{
count++;
}
}
printf(“%d”,count);
}

(A) 55
(B) 54
(C) 1
(D) 0

Ans:C


9. ‘break’ statement can be used in:

(A) loop only
(B) switch only
(C) both loop and switch
(D) any statement

Ans:C


10. ‘continue’ statement can be used in:

(A) loop only
(B) switch only
(C) both loop and switch
(D) any statement

Ans: A


11. consider the following code and give the answer:

#include <stdio.h>
int main()
{
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(i%2==0)
break;
}
}

(A) control comes out from if statement
(B) control comes out from both loop
(C) control comes out from inner loop only
(D) compilation error

Ans: C


12. Choose correct statement about Functions in C Language.

A) A Function is a group of c statements which can be reused any number of times.
B) Every Function has a return type.
C) Every Function may or may not return a value.
D) All the above.

Ans:D


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

void show();
int main()
{
show();
printf(“ARGENTINA “);
return 0;
}

void show()
{
printf(“AFRICA “);
}

A) ARGENTINA AFRICA
B) AFRICA ARGENTINA
C) ARGENTINA
D) Compiler error

Ans:B
C MCQ Set-7 Explanation


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

int show();
main()
{
int a;
printf(“PISTA COUNT=”);
a=show();
printf(“%d”, a);
}

int show()
{
return 10;
}

A) PISTA COUNT=
B) PISTA COUNT=0
C) PISTA COUNT=10
D) Compiler error

Ans:C
C MCQ Set-7 Explanation


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

int show();
void main()
{
int a;
a=show();
printf(“%d”, a);
}

int show()
{
return 15.5;
return 35;
}

A) 15.5
B) 15
C) 0
D) Compiler error

Ans:B


Spread the love

Leave a Comment

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