Taking Input till one Specific Number is Entered

Problem Statement
write a c program 
which takes input till 0 is entered
once 0 is entered it stops taking input and shows number of input taken

#include<stdio.h>
int main()
  
int a,c;  
printf("this program will stop reading when 0 is entered \n");   
printf("enter numbers \n");  
c=0;   
while(scanf("%d",&a),a!=0)    
{      c=c+1;    
} 
 printf("%d numbers read",c); 
 return 0;
}


No comments:

Post a Comment