Computer Programming (3310701) MCQs

MCQs of Loop Control Statements

Showing 11 to 20 out of 39 Questions
11.

What is the output of this C code?

#include <stdio.h>
void main()
{
         double k = 0;
         for(k = 0.0; k < 3.0; k++);
         printf("%lf", k);
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void main()
{
         double k = 0;
         for(k = 0.0; k < 3.0; k++);
         printf("%lf", k);
}

(a)

2

(b)

4

(c)

3

(d)

3.000000

Answer:

Option (d)

12.

What is the output of this C code?

#include <stdio.h>
void main()
{
         int i = 0;
         for (; ; ;)
         printf("In for loop\n");
         printf("After loop\n");
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void main()
{
         int i = 0;
         for (; ; ;)
         printf("In for loop\n");
         printf("After loop\n");
}

(a)

Compile time error

(b)

Infinite loop

(c)

After loop

(d)

In for loop
After loop

Answer:

Option (a)

13.

What is the output of this C code?

#include <stdio.h>
void main()
{
        do
              printf("In while loop ");
        while (0);
        printf("After loop\n");
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void 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

Answer:

Option (b)

14.

What is the output of this C code?

#include <stdio.h>
void main()
{
         int i = 0;
         do {
              i++;
              printf("In while loop\n");
         }while (i < 3);
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void 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

Answer:

Option (a)

15.

How many times i value is checked in the following C code?

#include <stdio.h>
void main()
{
          int i = 0;
          do {
                 i++;
                 printf("in while loop\n");
           } while (i < 3);
}

નીચે આપેલા C કોડમાં કેટલી વાર i ની વેલ્યુ ચેક કરવામાં આવે છે?

#include <stdio.h>
void main()
{
          int i = 0;
          do {
                 i++;
                 printf("in while loop\n");
           } while (i < 3);
}

(a)

2

(b)

3

(c)

4

(d)

1

Answer:

Option (b)

16.

How many times i value is checked in the following C code?

#include <stdio.h>
void main()
{
         int i = 0;
         while (i < 3)
          i++;
          printf("In while loop\n");
}

નીચે આપેલા C કોડમાં કેટલી વાર i ની વેલ્યુ ચેક કરવામાં આવે છે?

#include <stdio.h>
void main()
{
         int i = 0;
         while (i < 3)
          i++;
          printf("In while loop\n");
}

(a)

2

(b)

3

(c)

4

(d)

1

Answer:

Option (c)

17.

What is the output of this C code?

#include <stdio.h>
void main()
{
          int i = 2;
          do
          {
                   printf("Hi");
          } while (i < 2)
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void main()
{
          int i = 2;
          do
          {
                   printf("Hi");
          } while (i < 2)
}

(a)

Compile time error

(b)

Hi Hi

(c)

Hi

Answer:

Option (a)

18.

What is the output of this C code?

#include <stdio.h>
void main()
{
           int i = 0;
           do
           {
                     printf("Hello");
           } while (i != 0);
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void main()
{
           int i = 0;
           do
           {
                     printf("Hello");
           } while (i != 0);
}

(a)

Compile time error

(b)

Hello is printed infinite times

(c)

Hello

(d)

Run time error

Answer:

Option (c)

19.

What is the output of this C code?

#include <stdio.h>
void main()
{
        int i = 0;
        while (i < 10)
        {
                i++;
                printf("hi\n");
                while (i < 8) 
                {
                          i++;
                          printf("hello\n");
                }
         }
}

આપેલા C કોડનું આઉટપુટ શું હશે?

#include <stdio.h>
void main()
{
        int i = 0;
        while (i < 10)
        {
                i++;
                printf("hi\n");
                while (i < 8) 
                {
                          i++;
                          printf("hello\n");
                }
         }
}

(a)

Hi is printed 8 times, hello 7 times and then hi 2 times

(b)

Hi is printed 10 times, hello 7 times

(c)

Hi is printed once, hello 7 times

(d)

Hi is printed once, hello 7 times and then hi 2 times

Answer:

Option (d)

20.

Which loop is most suitable to first perform the operation and then test the condition?

પહેલા ઓપરેશન પરફોર્મ કરવા અને પછી કન્ડિશન ને ટેસ્ટ કરવા માટે કઈ લૂપ સૌથી વધુ યોગ્ય છે?

(a)

for loop

(b)

while loop

(c)

do-while loop

Answer:

Option (c)

Showing 11 to 20 out of 39 Questions