Program to display a positive number, if user enters negative number that number won't be displayed by using IF statement.
#include <stdio.h>
#include <stdlib.h>
main(void)
{
int n, Flag=1;
while(Flag)
{
printf("\nEnter a +ve number: "); scanf("%d",&n);
if(n>=0) printf("The number is %d",n);
printf("\n\nPress 1 to Continute or 0 to QUIT: "); scanf("%d",&Flag);
}
return(0);
}
Comments
Leave a comment