Friday, January 25, 2019

Write a program in C++ to find greatest among 4 numbers.

Write a program in C++ to find greatest among 4 numbers.

#include<iostream.h>
#include<conio.h>
 void main()
  {
   int a,b,c,d;
   clrscr();
   cout<<"Enter 4 nos.:-",
   cin>>a>>b>>c>>d;
   if(a>b&&a>c&&a>d)
      cout<<a<<" is greater.";
   else if(b>c&&b>d)
      cout<<b<<" is greater.";
   else if(c>d)
      cout<<c<<" is greater.";
   else
      cout<<d<<" is greater.";
   getch();
   }
Output:-

No comments:

Post a Comment