#include<iostream>
using namespace std;
int main()
{
int n,i,j,k;
cout<<"Enter your total number here";
cin>>n;
int a[n];
for(j=0;j<n;j++)
{
cout<<"Enter element at position " <<j+1<<" :";
cin>>a[j];
cout<<endl;
}
//maximum number
i=a[0];
k=0;
for(j=0;j<n;j++)
{
if (i<a[j])
i=a[j];
}
cout<<"maximum number is :"<<i<<endl;
//minimum number
i=a[0];
k=0;
for(j=0;j<n;j++)
{
if (i>a[j])
i=a[j];
}
cout<<"minimum number is :"<<i<<endl;
k=0;
for(j=0;j<n;j++)
{
k=k+a[j];
}
cout<<"sum of array is :"<<k<<endl;
return 0;
}
using namespace std;
int main()
{
int n,i,j,k;
cout<<"Enter your total number here";
cin>>n;
int a[n];
for(j=0;j<n;j++)
{
cout<<"Enter element at position " <<j+1<<" :";
cin>>a[j];
cout<<endl;
}
//maximum number
i=a[0];
k=0;
for(j=0;j<n;j++)
{
if (i<a[j])
i=a[j];
}
cout<<"maximum number is :"<<i<<endl;
//minimum number
i=a[0];
k=0;
for(j=0;j<n;j++)
{
if (i>a[j])
i=a[j];
}
cout<<"minimum number is :"<<i<<endl;
k=0;
for(j=0;j<n;j++)
{
k=k+a[j];
}
cout<<"sum of array is :"<<k<<endl;
return 0;
}
No comments:
Post a Comment