Monday 21, May 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

  program to show the greatest and smallest number from the given numbers

Program to show the greatest and smallest number from the given numbers using c++. If statement is used in this program.
Cut & Paste Script
#include<iostream.h>
int main()
{
    float num1,num2,num3,num4,num5,g,s;
    cout<<" Enter the first number   :   ";
    cin>>num1;
    cout<<" Enter the second number  :   ";
    cin>>num2;
    cout<<" Enter the third number   :   ";
    cin>>num3;
    cout<<" Enter the fourth number  :   ";
    cin>>num4;
    cout<<" Enter the fifth number   :   ";
    cin>>num5;
    g = num1;
    s = num1;
    if(g<num2)
        g = num2;
        if(g<num3)
            g = num3;
        if(g<num4)
            g = num4;
        if(g<num5)
            g = num5;
        cout<<" The greatest number is  "<<g<<endl;
        if(s>num2)
        s = num2;
        if(s>num3)
            s = num3;
        if(s>num4)
            s = num4;
        if(s>num5)
            s = num5;
        cout<<" The smallest number is  "<<s<<endl;
    return 0;
}

Output:
Enter the first number   :   1.5
Enter the second number  :   3
Enter the third number   :   9
Enter the fourth number  :   0.35
Enter the fifth number   :   9.1
The greatest number is  9.1
The smallest number is  0.35
Press any key to continue
 
   
     RELATED SCRIPTS
 
Sorting all characters of a string using c++
This program will sort all characters of a string....more »
Category : C++ Programs Hits : 314
   
Program to reverse a 2 digit number
This program will reverse a two (2) digit number. Input number must be of 2 digits....more »
Category : C++ Programs Hits : 596
   
Temperature conversion from Farenheit to Centigrade
Here is a c++ program for Temperature conversion from Farenheit to Centigrade....more »
Category : C++ Programs Hits : 640
   
Creating an array of objects using c++

Here is a program example to show how to declare an array of an object and use of array of an object.

...more »
Category : C++ Programs Hits : 1532
   
Calculate number of digits in a number using c++
Here is a c++ program example to calculate number of digits in a number entered by user....more »
Category : C++ Programs Hits : 587
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download Ajax Design Patterns  Ebook Ajax Design Patterns
   
Download The Amamzing Links Wizard Ebook The Amamzing Links Wizard
   
Download 5 Tips for successful Small Business Marketing Ebook 5 Tips for successful Small Business Marketing
   
Download Golden Adsense Strategy  Ebook Golden Adsense Strategy
   
Download Cashing in with Resell Rights Ebook Cashing in with Resell Rights
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz