Basic C coding problem The first two sample programs arrays1
Basic C++ coding problem
The first two sample programs (arrays_1.cpp, arrays_2.cpp) above should help you on this part. Write a program which declares an array of 6 integers, then prompt the user for 6 values, reads them in from the keyboard, and stores them in an array. You should use a loop to read in your values, as shown in arrays_2.cpp. Using a loop (different from the loop you wrote to read in the data) write them back to the console. Compile, test and run your program. REMEMBER: C++ arrays are indexed from 0 to n-1, not from 1 to n. So your loops should be from i=0 to iSolution
ans.1.a)
#include<iostream.h>
#include<conio.h>
main()
{
int a[i];
cout<<\"Enter array elements\";
int i;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
cout<<a[i];
}
int sum=0;
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
cout<<\"Sum is\";
cout<<sum;
float avg;
avg=sum/n;
cout<<\"Average is\";
cout<<avg;
for(i=0;i<n;i++)
{
cout<<a[i];
}
for(i=n-1;i>=0;i--)
{
cout<<a[i];
}
getch();
}


