¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita+ 3
C++
How do we write a program to calculate the largest element in an array of 10 cells
7 Respuestas
+ 5
logic part:
max=array[0];
for(i=0;i<10;i++)
{
if(max<array[i])
max=array[i];
}
+ 4
[ ] oops my bad 😥. You were right all along. How do you pronounce your name, brackets?
+ 1
Sonic Sonic when max is less than the array element then it implies that there is some other element present in array larger than max so the required element is that.....therefore max<array[i]
+ 1
i hope i am clear 😅!!
+ 1
Sonic lol actually its just blank ....its from a character of a show(anime pls dont judge me now) like yours ...but brackets is fine😁
+ 1
~ swim ~
As u wish sir.....but i guess there is not much harm in i=0
+ 1
#include<iostream>
using namespace std;
Int main()
{ int I,max,n,a[];
cout<<"\n enter limit";
cin>>n;
cout<<"\n enter array : ";
for(i=0;i<n;i++)
cin>>a[i];
max=a[0];
for( I=0;i<n;i++)
{ if(a[I]>max)
max=a[i];}
cout<<"\n maximum number is=";
cout<<max;
return 0;
}