Multiple choice

If we enter the number as 1111, which of the following statements about the above program is/are correct?

#include

#include

#include

#include

int main()

{

long n;

int x,y=0,p=0;

printf("enter number");

scanf(%d,&n);

while(n!=0)

   {

x=n%10;

i f(x>1 || x<0)

      {

printf("invalid" );

exit(1);

      }

y=y+x*pow(2,p);

n=n/10;

p++;

   }

printf("answer is %d",y);

getch();

}

  1. The program will find the sum of digits.

  2. The program will find the number of digits.

  3. Invalid

  4. The program will run infinite times.

  5. There is a error in the program.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This option is correct.