Computer Programming (3310701) MCQs

MCQs of Loop Control Statements

Showing 31 to 39 out of 39 Questions
31.

If c is a variable initialized to 1, how many times will the following loop be executed?

while ((c > 0) && (c < 60))
{
c ++;
}

જો c વેરીએબલ જે 1 થી ઇનિશિયલાઈઝ કરેલ હોય, તો નીચેની લૂપ કેટલી વાર ચલાવવામાં આવશે?

while ((c > 0) && (c < 60))
{
c ++;
}

(a)

60

(b)

59

(c)

61

(d)

Nothing

Answer:

Option (b)

32.

Choose the correct statement

સાચું સ્ટેટમેન્ટ પસંદ કરો

(a)

use of goto enhances the logical clarity of the code

ગોટુ નો યુઝ કોડની લોજીકલ ક્લેરિટીને વધારે છે

(b)

use of goto makes the debugging task easier

ગોટુ નો ઉપયોગ ડિબગીંગ ટાસ્ક ને વધુ ઇઝી બનાવે છે

(c)

use goto when you want to jump out of a nested loop

જયારે તમે નેસ્ડ લૂપમાંથી બહાર આવવા માંગતા ત્યારે ગોટુ નો યુઝ કરો

(d)

never use goto

ગોટુ નો યુઝ ક્યારેય ન કરો

Answer:

Option (c)

33.

What is the output of this C code?

for( i=1, j=10; i<6; ++i, --j )
printf ("%d %d", i, j );

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

for( i=1, j=10; i<6; ++i, --j )
printf ("%d %d", i, j );

(a)

1 10 2 9 3 8 4 7 5 6 

(b)

1 2 3 4 5 10 9 8 7 6 

(c)

1 1 1 1 1 1 9 9 9 9 9 

(d)

Error

Answer:

Option (a)

34.

What is the output of this C code?

for (i= 3; i < 15; i += 3)
{
printf ("%d ", i); 
++i;
}

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

for (i= 3; i < 15; i += 3)
{
printf ("%d ", i); 
++i;
}

(a)

3 6 9 12

(b)

3 6 9 12 15

(c)

3711

(d)

3 7 I I 15

Answer:

Option (c)

35.

How many times below for loop will be executed?

#include<stdio.h>
int main()
{
        int i=0;
        for(;;)
              printf("%d",i);
        return 0;
}

નીચે આપેલી ફોર લૂપ કેટલી વાર એક્ઝિક્યુટ થશે?

#include<stdio.h>
int main()
{
        int i=0;
        for(;;)
              printf("%d",i);
        return 0;
}

(a)

0

(b)

Infinite times

(c)

1

(d)

9

Answer:

Option (b)

36.

Which keyword can be used to terminate a for loop or while loop?

for loop અને while loop ને terminate કરવા માટે કયો કીવર્ડ યુઝ થાય છે?

(a)

continue

(b)

break

(c)

stop

(d)

exit

Answer:

Option (b)

37.

Guess the output?

#include<stdio.h>
void main()
{
       int i=0;
       while(i <= 256)
       {
               printf("%d",i);
               i++;
       }
}

આપેલા પ્રોગ્રામ નું આઉટપુટ શું હશે?

#include<stdio.h>
void main()
{
       int i=0;
       while(i <= 256)
       {
               printf("%d",i);
               i++;
       }
}

(a)

0 1 2 3 4 …. Till 256

(b)

0 1 2 3 4 … Till 255

(c)

1 2 3 4 …. Till 256

(d)

1 2 3 …. Infinite

Answer:

Option (a)

38.

Guess the output?

main()
{
        int i=1;
        do
        {
                 printf("%d..",i);
        }while(i--);
}

આપેલા પ્રોગ્રામ નું આઉટપુટ શું હશે?

main()
{
        int i=1;
        do
        {
                 printf("%d..",i);
        }while(i--);
}

(a)

0..1..

(b)

1..0..

(c)

0

(d)

-1

Answer:

Option (b)

39.

Guess the output?

int n=0,m;
for(m=1;m<=n+1;m++)
printf("%d",m);

આપેલા પ્રોગ્રામ નું આઉટપુટ શું હશે?

int n=0,m;
for(m=1;m<=n+1;m++)
printf("%d",m);

(a)

2

(b)

1

(c)

0

(d)

6

Answer:

Option (b)

Showing 31 to 39 out of 39 Questions