Answer to Question #215984 in C for Hemambar

Question #215984
determine the cumulative sum of n floating point numbers read a new number into the computer during each call to recursive function
Sample input:
n=3
Enter the number:0.8
Enter the number:0.1
Enter the number:0.2
Sample output:
Cumulative sum=1.1
1
Expert's answer
2021-07-13T04:30:40-0400
#include <stdio.h>


int main()
{
    int n;
    float num;
    printf("Enter n: ");
    scanf("%d",&n);
    float sum=0;
    for(int i=0;i<n;i++){
        printf("Enter the number: ");
        scanf("%f",&num);
        sum=sum+num;
    }
    printf("Cumulative sum= %f",sum);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS