The program finds the greatest element in an array entered by the user.
Overall, the program allows the user to enter any number of elements in an array and then finds and prints the greatest element in the array.
#include<iostream> using namespace std; //Program to find Greatest element in an array. int main() { int a[100],n,i,t; cout<<"\nEnter The Limit : "; cin>>n;//3 for(i=0; i<n; i++) { cout<<"\nEnter The Value : "; cin>>a[i]; }//10,20,30 t=a[0];//10 for(i=1; i<n; i++) { if(t<a[i])//10<20 20<30 { t=a[i];//20 30 } } cout<<"\nThe Greatest No is : "<<t; return 0; }
Enter The Limit : 5 Enter The Value : 23 Enter The Value : 12 Enter The Value : 34 Enter The Value : 2 Enter The Value : 34 The Greatest No is : 34To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions