Custom Search

Friday, 13 January 2012

WAP, Write a C or C++ program to find biggest number from the entered 3 numbers with output using else if statement

WAP, Write a C or C++ program to find biggest number from the entered 3 numbers with output using else if statement


Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the three values");
scanf("%d %d %d, &a, &b, &c);
if(a>b && a>c)
{
printf ("%d", a);
}
else if (b>c && b>a)
{
printf("%d", b);
}
else if (c>a && c>b)
{
printf("%d", c);
}
getch();
}

Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h" 
2.)  for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.

Click here to check the output

No comments:

Post a Comment

Laptops