Answer to Question #318807 in C for Lee

Question #318807

Write a c program that must perform the following functionality in the main function declare a 3×5 array of a whole number, separetely prompt the user to enter 5 whole numbers using for row one using a FOR loop, separetely prompt the user to enter 5 whole numbers using WHILE loop, Multiply the elements in row one in with the elements in row two and updated to row three of array using a DO WHILE loop then use a IF statement to determine if the product is an even or odd number and then print out the number followed by whether is even or odd

1
Expert's answer
2022-03-27T04:37:58-0400
#include <stdio.h>

int main()
{
    int i, j;
    int array[3][5];
    printf("Input first line:\n");
    for (i=0; i<5; i++)
        scanf("%d", &array[0][i]);
    printf("Input second line:\n");
    i = 0;
    while (i<5)
    {
        scanf("%d", &array[1][i]);
        i++;
    }
    i=0;
    do
    {
        array[2][i] = array[0][i] * array[1][i];
        i++;
    } while (i<5);
    printf("\nArray:\n");
    for (i=0; i<3; i++)
    {
        for (j=0; j<5; j++)
            printf("%d ", array[i][j]);
        printf("\n");
    }
    printf("\n");
    for (i=0; i<5; i++)
        if ((array[2][i] % 2) == 0)
            printf("%d - Even\n", array[2][i]);
        else
            printf("%d - Odd\n", array[2][i]);
    getchar();
    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