Sunday, July 30, 2017

Write a program that will ask the user to input three integer values from the keyboard. Then it will print the smallest and largest of those numbers.

/*
For more exercises and lessons, visit http://shegertech.blogspot.com/
*/

#include <cstdlib>
#include <iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int maxval(int a,int b,int c){
     if(a>b){
      if(a>c) return(a);
      else return(c);}
     else if(b>c) return(b);
     else return(c);
   
     }
int minval(int a,int b,int c){
     if(a<b){
      if(a<c) return(a);
      else return(c);}
     else if(b<c) return(b);
     else return(c);
   
     }
int main()
{
  int a,b,c;
  cout<<"Enter three integer numbers:";
  cin>>a>>b>>c;
  cout<<"Max="<<maxval(a,b,c);cout<<"\n";
  cout<<"Min="<<minval(a,b,c);
  cout<<"\n";
  system("PAUSE");
  return EXIT_SUCCESS; }

Share: