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

Create 3 arrays of 5 elements of double type. Then use fscanf( ) with a for loop

ID: 3618003 • Letter: C

Question

Create 3 arrays of 5 elements of double type. Then use

fscanf( ) with a for loop to fill the first array. Use hardcoding method as indicated in the class notes to fill the secondarray.

The third array is used to store the sum of the first twoarrays, that is first element of first array is added to the firstelement of the second array and the result is assigned to the firstelement of the third array and so on. Use a for loop to do theadding.

Then use a for loop to print the result in a table format likethe following:-

     Firstarray           Secondarray            sum

       2.00                           10.02            12.02

       3.00                           20.05           23.05       

       --                                --                  --    

Explanation / Answer

Hope you will Rate Hope you will Rate..
#include<stdio.h> #include<conio.h> void main() { float first[5],second[5],third[5]; int v; for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&first[v]); }
printf(" Second array ");
for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&second[v]); third[v]=first[v]+second[v]; }
printf("First Array Second Array Third Array "); for(v=0;v<5;v++) { printf("%f %f %f",first[v],second[v],third[v]); printf(" "); }
getch(); }
#include<stdio.h> #include<conio.h> void main() { float first[5],second[5],third[5]; int v; for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&first[v]); }
printf(" Second array ");
for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&second[v]); third[v]=first[v]+second[v]; }
printf("First Array Second Array Third Array "); for(v=0;v<5;v++) { printf("%f %f %f",first[v],second[v],third[v]); printf(" "); }
getch(); } #include<stdio.h> #include<conio.h> void main() { float first[5],second[5],third[5]; int v; for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&first[v]); }
printf(" Second array ");
for(v=0;v<5;v++) { printf(" Enter element : "); scanf("%f",&second[v]); third[v]=first[v]+second[v]; }
printf("First Array Second Array Third Array "); for(v=0;v<5;v++) { printf("%f %f %f",first[v],second[v],third[v]); printf(" "); }
getch(); }