Your task is the create the algorithm or flowchart for the following tasks Task
ID: 3865464 • Letter: Y
Question
Your task is the create the algorithm or flowchart for the following tasks Task #1 - a. Write a program that will create two one-dimensional arrays with the names. Array 1, Array 2 of integer data type with 8 elements. Initialize the arrays with 0's when they are declared. b. Display the contents of Array 1 and Array 2. Task #2 - Modify Task # 1 program so that it will do the following a. Prompt the user to enter the following numbers in Array 1 11, 17, 34, 6, 20, 10, 4, 9 b. Display the contents of Array 1 c. Use the random number generator to add the 8 numbers in Array 2 between 4 to 20. d. Display the contents of Array2 Task #3 - Modify Task #2 program that will do the following a. Create 2 additional 8-element integer arrays name sumArray and productArray. b. initialize the arrays with 0's c. Display the contents of sumArray and productArray d. Add the contents of Array 1 and Array 2 and store in sumArray e. Display the contents of sumArray f. Multiply the contents of Array 1 by Array 2 and store in productArray g. Display the contents of productArray Task #4 - a. Find the largest number in sumArray and display it b. Find the smallest number in productArray and display it Task #5 - a. Write a program that will create a two-dimensional 8 times 8-character array name boardArray and initialize the array with *'s when it is declared. b. Display the contents of boardArray.Explanation / Answer
1 a) int array1[ 10 ]={0,0,0,0,0,0,0,0,0,0};
int array2[ 10 ]={0,0,0,0,0,0,0,0,0,0};
1 b)
for (j = 0; j < 10; j++ ) {
printf(" %d ", j, array1[j] );
}
task 2
a) and b)
#include <iostream>
using namespace std;
int main()
{
int array1[10];
int i;
printf("Enter five numbers. ");
for (i=0; i<10; i++) {
printf("Enter number %d: ", i+1);
scanf("%d", &array[i]);
}
for (i=0; i<10; i++) {
printf("%d", array[i]);
}
return 0;
}
task 2) c) and d)
#include <iostream>
using namespace std;
int main()
{
int array[8], i;
for(i = 0; i < 8; i++)
{
array[i] = (rand() % 20)+1;
printf("%4d ", array[i]);
}
return 0;
}
Task 3 consolidated
#include <iostream>
using namespace std;
int main()
{
int i,a[5],b[5],sumArr[5],productArr[5];
printf(" Reading the 1st array ");
for (i=0;i<5;i++)
{
printf("Enter the value");
scanf("%d",&a[i]);
}
printf(" Reading the 2nd array ");
for (i=0;i<5;i++)
{
printf("Enter the value");
scanf("%d",&b[i]);
}
printf(" The output of addition of 2 array is ");
for(i=0;i<5;i++)
{
sumArr[i]=a[i]+b[i];
productArr[i]=a[i]*b[i];
printf(" the sum of %d & %d is %d",a[i],b[i],sumArr[i]);
printf(" the product of %d & %d is %d",a[i],b[i],productArr[i]);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.