/*5. C Program to read numbers from keyboard continuously till the user presses 999 and find sum of positive numbers */
#include<stdio.h>
void
main()
{
int num, sum=0;
clrscr();
while(1)
{
printf("Enter any number:");
scanf("%d",&num);
if(num>0 && num!=999)
{
sum=sum+num;
}
if(num==999)
{
printf("Sum of Positive
numbers=%d",sum);
getch();
exit(0);
}
}
getch();
}
No comments :
Post a Comment