prev | for loop 109.Sum of Positive , Negative numbers (31.05.2010) /* Program# 109 date : 14-01-2009 Sum of Positive , Negative */ #include <stdio.h> main(){ int n; int p_sum,ne_sum; p_sum=ne_sum=0; for(scanf("%d",&n);n!=-1000;scanf("%d",&n)){ if(n>0) p_sum+=n; else if(n<0) ne_sum+=n; } printf("\n Positive sum: %d \n Negative Sum : %d",p_sum,ne_sum); } |
next |