Tuesday, 5 January 2016

FIND INDEX OF LARGEST NUMBER IN ARRAY in c++

FIND INDEX OF LARGEST NUMBER IN ARRAY in c++

 Cplusplus, How to find biggest index of array .

Structure of the Problem Requirements  
The Program find the biggest index number of an array in C++ Program. The user will enter five numbers in array and then find the biggest number in them .
Source Code 
#include<iostream>
using namespace std;
int main ()
{
 int num[5];
 int a;
 int index;
 for ( int i =0; i<5;i++ )
 {
  cout<<" Enter Your Number : ";
  cin>>num[i];
 }
 for (int i =0; i <5;i++)
 {
  if (num[i]>a)
  {
  a = num [i];
  index = i;
  }
 }
 cout<<" The Index of Biggest Number is : "<<index;
}


No comments:

Post a Comment