Create a project called Daily20. Add a source file called daily20.c into the project. In this exercise, you will practice working with an array of integers. Write a program that creates an integer array with 40 elements in it. Use a for loop to assign values of each element to the array so that each element has a value that is twice its index. For example the element with index 0 should have a value of 0, the element with index 1 should have a value of 2, the element with index 2 should have a value of 4 and so on. Once the array is initialized, output the array to the screen with 10 elements per line where each element is right justified in a column that is 7 characters wide. On the line after the array is printed, output a line that has 5 asterisks (\'*\') in it as a divider. Reverse the array elements in the array you created above, i.e., after reversal, the first element in the array should store 78, the second element should store 76, ..., and the last element in the array should store 0. You may NOT use a second array to help your reversal. Then output the reversed array to the screen in the same way as above. This means that you are not asked to just output the initial array in the reversed order. Try to write a function to print the array and call it twice in your program. Your output should look something like the following:
#include <stdio.h>
//declare const to hold no of elemnts
const int size=40;
//print fucntion to print the elements in array
void print(int nos[size])
{
int max_width = 7;
for(int i=0;i<size;i++)
{
if(i%10==0)
printf(\"\ \");
printf(\"%*d\",max_width,nos[i]);
}
}
//main fucntion
int main()
{
//declare variables
int nos[size];
//initialize elemtns in array
for(int i=0;i<size;i++)
{
nos[i]=i*2;
}
//print array after done with initilaization
print(nos);
printf(\"\ *****\");
//reverse array
for(int i=0;i<size/2;i++)
{
int temp;
temp=nos[i];
nos[i]=nos[size-i-1];
nos[size-i-1]=temp;
}
print(nos);
return 0;
}