Link to home
Create AccountLog in
Avatar of mustish1
mustish1

asked on

Largest number

Hi guys: Can any one please tell me what i made mistake as it dont shows the largest number. Thanks.
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
  {
      int x = 0 , max = 0;
      cout << "Please input number, input a negative value to find largest number:";
      cin >> x;
      while(x >= 0)
      {
            if ( x > max)
                  max = x;
            x++;
      }

cout << "The largest number is: ";
cout << max;
system("pause");
return 0;
}
SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of mustish1
mustish1

ASKER

Thanks