Program to find large number in four numbers using nested if.....
#include <iostream.h>
int main ()
{
int a,b,c,d;
cout<<”\n Enter four numbers:”;
cin>>a>>b>>c>>d;
if (a>b)
{
if (a>c)
{
if (a>d)
cout<<”\n Largest number is : ”<<a;
else
cout<<”\n Largest number is : ”<<b;
}
else
{
if (c>d)
cout<<”\n Largest number is : ”<<c;
else
cout<<”\n Largest number is : ”<<d;
}
}
else
{
if (b>c)
{
if (b>d)
cout<<”\n Largest number is : ”<<b;
else
cout<<”\n Largest number is : ”<<d;
}
else
{
if (c>d)
cout<<”\n Largest number is : ”<<c;
else
cout<<”\n Largest number is : ”<<d;
}
}
return 0;
}
No comments:
Post a Comment