Maximum in array in C++ by R4R Team

What is Array?
Array is a linear data structure in C++ which store similar kind of data like integer array, char array, float araray etc.
-collection of different data type are not allowed in array like
-collection of integer and string is not the array

Syntax-
data_type variable_name[size];

Example-
int var[20];
char s[20];

How find maximum in array?

program:

#include< iostream>
using namespace std;
int main()
{
int a[10],i,max;
cout<<"Enter 10 elements in arrayn";
for(i=0;i< 10;i++)
cin>>a[i];
max=a[0];
for(i=1;i< 10;i++)
if(a[i]>max)
max=a[i];
cout<<"Maximum is: "< return 0;
}


output-

Enter 10 elements in array
2 6 19 21 12 0 1 4 6 7
Maximum is: 21




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!