Make Your Search Easy ! :) Use me

Thursday, August 10, 2017

Program to find the greatest number and its frequency from a series of inputs, without storing all the inputs.


#include<iostream.h>
#include<conio.h>

void main()
{
         int max=0,num,i,j=0,flag=0;
         cout<<"Enter the number of inputs to be entered :";
         cin>>i;
         do
          {
          cout<<"Enter number "<<(j+1)<<"  : ";
            cin>>num;
            if(num>max)
            {
            max=num;
                  flag=0;
               }
            if(num==max)
            {
                flag++;
               }
            j++;
          }while(j<i);
         cout<<"\n\nGreatest number is : "<<max<<endl;
         cout<<"Frequency of greatest number is : "<<flag;
         getch();

   }

No comments:

Post a Comment