C-Programming :- Sum and Count of Numbers Source Code




a) StartRAPTORandcreateaflowchartthatcountsthenumbersenteredbytheuser and computes the sum of positive numbers.
b) Your flowchart continues asking for a number until the user decides to stop and the result will be displayed. 



#include<stdio.h>
int main(void)
{
char op='n';
float n,sum=0;
int count=0;
while(op!='Y' && op!='y')
{
        printf("Enter a number:\n");
        scanf("%f",&n);
        if(n>0) sum+=n;
        printf("Exit (Y/N)?\n");
        scanf(" %c",&op);
count++;
}
printf("Sum of the positive numbers = %.2f , Count =%d\n",sum,count);
return 0;
}

Comments