Description:
This program define elements of array and perform different operations on elements of array. In C++ array is used to store values at different indexes of array.
Code:
This program define elements of array and perform different operations on elements of array. In C++ array is used to store values at different indexes of array.
Code:
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
int i,j,k,sum,avrg;
float a[5];
cout<<"Enter values of elements of array"<<endl;
for(i=0;i<=4;i++)
{cout<<"a["<<i<<"]"<<" =";
cin>>a[i];
}
cout<<"your entered values of array are"<<endl;
for(i=0;i<=4;i++)
cout<<a[i];
sum=avrg=0;
for(i=0;i<=4;i++)
sum=sum+a[i];
avrg=sum/5;
cout<<endl<<"The sum of elements of array is"<<endl<<sum<<endl;
cout<<"The average of elements of array is"<<endl<<avrg<<endl;
getche();
return 0;
}
No comments:
Post a Comment