Read the question in the picture below very carefully Its an
Read the question in the picture below very carefully.
It\'s an assignment over arrays. for loop and while loop.
Question and the sample (example of an) output is given for better understanding
Description: In this homework, we will implement what we just learned about arrays with our previous work on loops. Problem: Create two finite arrays with the same number of elements (anywhere from 5 to 15 elements in each array, you pick). Ask the user for a starting value to fill in the arrays Use a FOR loop or WHILE loop to initialize the 1st array, starting at the value given by the user, and with each element incrementing by 1. For example: array10 1, 2, 3, 4, 5, 6 if the user enters 1 as the value for an array with 6 elements. Use another loop to assign array1\'s elements to array2 in descending order. For example, if array1 11, 12, 13), then array2 {13, 12, 11h. Print out the result of both arrays. Sample output For an array with just 4 elements: Please enter a starting value for the array: 21 Array 100]: 21 Array 1[1]: 22 Array 112]: 23 Array 1[3]: 24 Array 200]: 24 Array 201]:23 Array 202]: 22 Array 203]: 21Solution
#include<stdio.h>
#include<conio.h>
void main()
{
int Array1[5],Array2[5],n,j=4;
printf(\"Please enter a starting value for the array :\");
scanf(\"%d\",&n);
for(int i=0;i<=4;i++)
{
Array1[i]=n;
n++;
}
printf(\"\ Array1[0] : %d\",Array1[0]);
printf(\"\ Array1[1] : %d\",Array1[1]);
printf(\"\ Array1[2] : %d\",Array1[2]);
printf(\"\ Array1[3] : %d\",Array1[3]);
printf(\"\ Array1[4] : %d\",Array1[4]);
for(int i=0;i<=4;i++)
{
Array2[i]=Array1[j];
Array2[j]=Array1[i];
j--;
}
printf(\"\ Array2[0] : %d\",Array2[0]);
printf(\"\ Array2[1] : %d\",Array2[1]);
printf(\"\ Array2[2] : %d\",Array2[2]);
printf(\"\ Array2[3] : %d\",Array2[3]);
printf(\"\ Array2[4] : %d\",Array2[4]);
clrscr();
}

