MCQ Computer Science

C Programming Questions and Answers – While Loops – 1

C Programming Questions and Answers – While Loops – 1

 

1. What is the output of this C code?

#include <stdio.h>
int main()
{
while ()
printf(“In while loop “);
printf(“After loop\n”);
}
a) In while loop after loop
b) After loop
c) Compile time error
d) Infinite loop

View Answer

Answer:c

2. What is the output of this C code?

#include <stdio.h>
int main()
{
do
printf(“In while loop “);
while (0);
printf(“After loop\n”);
}
a) In while loop
b) In while loop
after loop
c) After loop
d) Infinite loop

View Answer

Answer:b

3. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf(“In while loop\n”);
} while (i < 3);
}
a) In while loop
In while loop
In while loop
b) In while loop
In while loop
c) Depends on the compiler
d) Compile time error

View Answer

Answer:a

4. How many times i value is checked in the below code?

#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf(“in while loop\n”);
} while (i < 3);
}
a) 2
b) 3
c) 4
d) 1

View Answer

Answer:b

5. How many times i value is checked in the below code?

#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf(“In while loop\n”);
}
a) 2
b) 3
c) 4
d) 1

View Answer

Answer:c

6. What is the output of this C code?

#include <stdio.h>
void main()
{
int i = 2;
do
{
printf(“Hi”);
} while (i < 2)
}
a) Compile time error
b) Hi Hi
c) Hi
d) Varies

View Answer

Answer:a

7. What is the output of this C code?

#include <stdio.h>
void main()
{
int i = 0;
while (++i)
{
printf(“H”);
}
}
a) H
b) H is printed infinite times
c) Compile time error
d) Varies

View Answer

Answer:b

8. What is the output of this C code?

#include <stdio.h>
void main()
{
int i = 0;
do
{
printf(“Hello”);
} while (i != 0);
}
a) Nothing
b) H is printed infinite times
c) Hello
d) Run time error

View Answer

Answer:c

For more Visit the Link:

Computer Science MCQ All Topic C programming MCQ All Topic

Related Articles

Leave a Reply

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

Back to top button