Skip to main content
Write a program to find largest number of an array in C++ Language - Program to find largest number of an array in C++
Program to find largest number of an array in C++ Language
#include <iostream>
using namespace std;
int main() {
int i, n;
float a[50];
cout << endl << "Enter Total Numbers = ";
cin >> n;
cout << endl;
for(i = 0; i < n; ++i)
{
cout << endl << "Enter Number " << i + 1 << " = ";
cin >> a[i];
}
for(i = 1;i < n; ++i)
{
if(a[0] < a[i])
a[0] = a[i];
}
cout << endl << endl << "Largest number is = " << a[0] << endl;
return 0;
}
इस कोड को हमने CODEBLOCK पर बना कर run किया है
Comments
Post a Comment