Which of the following statements about the above program is correct if we enter the number as 1111?
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
long n;
int x,y=0,p=0;
printf("enter number");
scanf(%d,&n);
while(n!=0)
{
x=n%10;
if(x>1 || x<0)
{
printf("invalid" );
exit(1);
}
y=y+x*pow(2,p);
n=n/10;
p++;
}
printf("answer is %d",y);
getch();
}
Reveal answer
Fill a bubble to check yourself