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

Question #179306

Declare three arrays:

A, B and C each size 3 

Read these numbers into A using for loop and cin : 1, 2, 3

Read these numbers into B using for loop and cin: -1, -2, -3

C is A + B . this means you need to add each element of the array A to corresponding element of array B and then C is the sum.

Print the elements of array C (three elements)


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


int main()
{
    double A[3];
    double B[3];


    int i;
    for(i = 0; i < 3; i++)
    {
        printf("Enter number #%d: ",i+1);
        scanf("%lf", &A[i]);
    }
    printf("\n\n");


    for(i = 0; i < 3; i++)
    {
        printf("Enter number #%d: ",i+1);
        scanf("%lf", &B[i]);
    }




    double C[3];


    for(i = 0; i < 3; i++)
        C[i] = A[i]+B[i];


    printf("\n\nOutput\n");


    for(i = 0; i < 3; i++)
        printf("%g ",C[i]);


    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