C++ program to find out largest of three given numbers. The program will accept three numbers and then print the largest of three numbers. In this program if statement is used with and (&&) operator.
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a,b,c;
cout<<"Enter Value of A : ";
cin>>a;
cout<<"Enter Value of B : ";
cin>>b;
cout<<"Enter Value of C : ";
cin>>c;
if (a>b && a>c)
cout<<endl<<"The largest no. is A";
if (b>a && b>c)
cout<<endl<<"The largest no. is B";
if (c>a && c>b)
cout<<endl<<"The largest no. is C";
getch();
}
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a,b,c;
cout<<"Enter Value of A : ";
cin>>a;
cout<<"Enter Value of B : ";
cin>>b;
cout<<"Enter Value of C : ";
cin>>c;
if (a>b && a>c)
cout<<endl<<"The largest no. is A";
if (b>a && b>c)
cout<<endl<<"The largest no. is B";
if (c>a && c>b)
cout<<endl<<"The largest no. is C";
getch();
}
No comments:
Post a Comment