Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 0.86 KB | Hits: 62 | Expires: Never
Copy text to clipboard
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6.     //declaration
  7.    
  8.     double num1, num2, num3, LargestNum;
  9.    
  10.     //number input
  11.    
  12.     cout << "Enter a number: ";
  13.     cin >> num1;
  14.    
  15.     cout << "Enter another number: ";
  16.     cin >> num2;
  17.    
  18.     cout << "Enter yet another number: ";
  19.     cin >> num3;
  20.    
  21.     //finding the largest number
  22.    
  23.         if (num1>num2)
  24.         {
  25.          LargestNum = num1;
  26.         }
  27.        
  28.         else if (num2>num1)
  29.         {
  30.          LargestNum = num2;
  31.         }
  32.        
  33.         if (num2>LargestNum)
  34.         {
  35.          LargestNum = num2;
  36.         }
  37.        
  38.         if (num3>LargestNum)
  39.         {
  40.          LargestNum = num3;
  41.         }
  42.    
  43.     //displaying the largest number
  44.    
  45.     cout << "\nThe largest number is: " << LargestNum << endl;
  46.    
  47.     system("pause");
  48.     return 0;
  49.    
  50. }