TO ACCEPT N NUMBERS AND DISPLAY SUM OF ALL POSITIVE & NEGATIVE NUMBERS


#include<stdio.h>
void main()
{
int n, pSum = 0, nSum = 0, num;
printf("Enter how many numbers you want print");
scanf("%d",&n);
for(; n>0; n--)
{
printf("Enter a number: ");
scanf("%d",&num);
if(num > 0)
pSum += num;
else
nSum += num;
}
printf("Sum of\n +ve number = %d\n-ve number = %d",pSum,nSum);
}

1 comments: (+add yours?)

Unknown said...

thanks man...

Post a Comment