This is a C++ program that finds the largest element in an array of integers.
#include <iostream> using namespace std; int main() { int n,largest; int num[50]; cout<<"\nEnter number of elements you want to enter: "; cin>>n; for(int i=0;i<n;i++) { cout<<"\nEnter Element "<<(i+1)<<": "; cin>>num[i]; } largest = num[0]; for(int i=1;i<n;i++) { if(largest < num[i]) largest = num[i]; } cout<<"\nLargest element in array is: "<<largest; return 0; }To download raw file Click Here
Enter number of elements you want to enter: 5 Enter Element 1: 11 Enter Element 2: 12 Enter Element 3: 13 Enter Element 4: 14 Enter Element 5: 15 Largest element in array is: 15
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions