Examveda
Examveda

What is the right choice, if the following loop is implemented?
void main()
{
   int num = 0;
   do{
      --num;
      printf("%d", num);
   }while( ++num >= 0 );
}

A. A run time error will be generated.

B. The program will not enter into the loop.

C. There will be a compilation error reported.

D. The loop will run infinitely many times.

E. Prints the value of 0 one time only.

Answer: Option D

Solution(By Examveda Team)

As the value of num is decremented(--num) and again incremented(++num) and hence no change in num and it remains 0 only causing infinite loop.


This Question Belongs to C Program >> Control Structures

Join The Discussion

Comments ( 1 )

  1. Merazur Rahaman
    Merazur Rahaman :
    2 years ago

    The Out put will be -1 for infinite times

Related Questions on Control Structures