Coding:-
#include<iostream.h>
int sum (int a[])
{
int n=0;
for(int i=0;i<=5;i++)
n=n+a[i];
return (n);
}
int output(int a[])
{
cout<<"the elements of array are : "<< endl ;
for(int i=0;i<=5;i++)
cout<<a[i]<<endl;
}
int main()
{
int a[6],s,i;
cout<<"enter 6 elements : ";
for(i=0;i<=5;i++)
cin>>a[i];
output(a);
cout<<"sum of array element is : ="<<sum(a)<<endl;
}
Output:-
#include<iostream.h>
int sum (int a[])
{
int n=0;
for(int i=0;i<=5;i++)
n=n+a[i];
return (n);
}
int output(int a[])
{
cout<<"the elements of array are : "<< endl ;
for(int i=0;i<=5;i++)
cout<<a[i]<<endl;
}
int main()
{
int a[6],s,i;
cout<<"enter 6 elements : ";
for(i=0;i<=5;i++)
cin>>a[i];
output(a);
cout<<"sum of array element is : ="<<sum(a)<<endl;
}
Output:-
No comments:
Post a Comment