Answer to Question #179305 in C++ for Hovannes Piloshian

Question #179305

create an array (call it arr) of size 5

In a for loop , use scanf to read 5 numbers into your array 

then use another for loop to add the 5 numbers in the array together and print the result.


1
Expert's answer
2021-04-07T20:03:11-0400
#include <stdio.h>


int main()
{
    double arr[5];
    int i;
    for(i = 0; i < 5; i++)
    {
        printf("Enter number #%d: ",i+1);
        scanf("%lf", &arr[i]);
    }


    double total = 0;
    for(i = 0; i < 5; i++)
        total += arr[i];


    printf("\nTotal: %g ", total);
    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