Program to read
numbers from keyboard continuously till the user presses 999 and to find the
sum of only positive numbers
#include<stdio.h>
void main()
{
int num,sum=0;
printf("Enter numbers to
:\n");
while(1)
{
scanf("%d",&num);
if(num==999)
break;
else
{
if(num>0)
sum+=num;
}
}
printf("Sum of positive numbers
is %d",sum);
}
0 Comments