Q. 94. Program to input 'n' numbers into an array. Find the biggest among them and print its position (array index position + 1).
#include <iostream>
using namespace std;
int main()
{
int a[25], n, i, bg = 0, pn = 0;
cout << " How many numbers can you provide? -> " ;
cin >> n ;
cout << "Enter " << n << " numbers \n" ;
for ( i = 0 ; i < n ; ++i)
{
cin >> a [ i ] ;
if (a[ i ] > bg)
{
bg = a[ i ] ; pn = i ;
}
}
cout << "Biggest Number is -> " << bg << " at position " << pn+1;
return 0;
}
No comments:
Post a Comment