Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Greetings everyone, i have this assignment and im trying to use three loops in a

ID: 3863825 • Letter: G

Question

Greetings everyone, i have this assignment and im trying to use three loops in a array but im missing one loop. here are the instructions.

Write a small program that:

fills an array of doubles with user input,

prints the doubles on the screen in a column,

adds up all the doubles in the array

prints the sum onto the screen.

- You must use at least 3 functions
- Declare an array of doubles of size 12.
- Prompt the user for how many doubles they want to enter <= 12.
- Use a loop to read the doubles into the array from the keyboard.
- Use a loop to print the array onto the screen in a column.
- Use a loop to add up all the items in the array and store the sum
- print the sum onto the screen

Please help me and it is in program C not C++.

Thank you

Explanation / Answer

#include <stdio.h>

int main()
{
    double array[12];
    int numOfValues;
   printf("Please how many doubles you want to enter(<=12):");
   scanf("%d",&numOfValues);
   int i=0;
   for( i=0;i<numOfValues;i++){
       printf("Enter Value for positon %d :",i);
       scanf("%lf",&array[i]);
   }
   for(i=0;i<numOfValues;i++){
       printf("Array[%d] :%lf ",i,array[i]);
   }
   double total = 0.0d;
   for(i=0;i<numOfValues;i++){
       total +=array[i];
   }

   printf("Sum of all Values is %lf ",total);
   return 0;
}

///============================ OUTPUT ========================//

Please how many doubles you want to enter(<=12):5                                                                                                                                           

Enter Value for positon 0 :12.                                                                                                                                                              

Enter Value for positon 1 :32                                                                                                                                                               

Enter Value for positon 2 :44                                                                                                                                                               

Enter Value for positon 3 :34.6                                                                                                                                                             

Enter Value for positon 4 :23.44                                                                                                                                                            

Array[0] :12                                                                                                                                                                                

Array[1] :32                                                                                                                                                                                

Array[2] :44                                                                                                                                                                                

Array[3] :34.6                                                                                                                                                                              

Array[4] :23.44                                                                                                                                                                             

Sum of all Values is 146.04