#include<stdio.h>
int main()
{
int n,sum,num,i;
printf("Enter a Number:\n");
scanf("%d",&n);
printf("Enter %d positive integer numbers: \n",n);
sum=0;
for(i=1;i<=n;i++)
{
printf("Enter %d postive integer number\n",i);
scanf("%d",&num);
if(num<0)
{
printf("Entered Negative no.\n");
i--;
continue;
}
sum=sum+num;
}
printf("Sum is %d",sum);
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter a Number:
3
Enter 3 positive integer numbers:
Enter 1 postive integer number
10
Enter 2 postive integer number
20
Enter 3 postive integer number
50
Sum is 80