Question

In: Computer Science

Write a program in C (NOT C++ or C#) The program inputs 5 elements into each...

Write a program in C (NOT C++ or C#)

The program inputs 5 elements into each of 2 integer arrays.

Multiply corresponding array elements, that is, arrayOne[0] * arrayTwo[0], etc.

Save the product into a third array called prodArray[ ].

Display the product array.

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.

#include <stdio.h>

int main()
{
//Declare the arrays each of size 5
   int arrayOne[5], arrayTwo[5], prodArray[5];
   int i=0;
   //Read the 5 numbers in First array and 5 numbers in Second array
   printf("Enter 5 numbers of first array: ");
   for(i=0;i<5;i++)
   scanf("%d",&arrayOne[i]);
  
   printf("Enter 5 numbers of Second array: ");
   for(i=0;i<5;i++)
   scanf("%d",&arrayTwo[i]);
  
   //Calculate the product and store it in productArray
   for(i=0;i<5;i++)
   prodArray[i] = arrayOne[i] * arrayTwo[i];
  
   //print the prodArray
   printf("The Product array is: ");
   for(i=0;i<5;i++)
   printf("%d ",prodArray[i]);
     
   return 0;
}

=================================

SCREENSHOT:


Related Solutions

Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
Write a C++ program that inputs two simplified poker hands (as defined in homework #5) and...
Write a C++ program that inputs two simplified poker hands (as defined in homework #5) and determines which (if either) of the hands is the winner, according to the following rules: • If the two hands have different types (3-of-kind, straight, pair, high-card), the hand with the better type (i.e., appears earlier in this list) wins. • If they have the same type, the higher significant card wins. • If the hands have the same type and significant card, there...
1. Write a program in C++ that takes as inputs a positiveinteger n and a...
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?2.  Write a program in C++ that takes as input a positive integer n and computes the following productsum...
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an...
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an array. Print all unique elements of an array Enter the number of elements to be stored in the array: 4 Input 4 elements in the arrangement: element [0]: 3 element [1]: 2 element [2]: 2 element [3]: 5 Expected output: The only items found in the array are: 3 5
Code in C Write a program whose inputs are three integers, and whose outputs are the...
Code in C Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values. int...
Write a C++ program that inputs the world's population at the end of last year. Assume...
Write a C++ program that inputs the world's population at the end of last year. Assume population is growing at a rate of 1.12%. Output the year (starting with this year) and the population until the population is greater than 10billion. Test data: 6.83 billion. (leave like this rather than 6800000000). Name as a comment and printed to output. Output as a comment at the bottom of the code
C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in...
C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements in the arrangement: element [0]: 5 element [1]: 1 element [2]: 1 Expected output: The total number of duplicate elements found in the array is: 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT