//The following is very simple program that will find the largest of any 3 numbers
#include <iostream>
using namespace std;
int main()
{
int n1, n2, n3, largest;
cout <<"Enter any 3 numbers ";
cin >>n1;
cin >>n2;
cin >>n3;
if(n1 > n2 && n1 > n3)
largest= n1;
else if(n2 >n1 && n2 >n3)
largest= n2;
else
largest= n3;
return 0;
}
The most common way is to use a function that returns the max of two values, passing the result of that into the same function along with the third value. The other solution is to pass all three into a single function call. It makes no real difference which you use as inline expansion would eliminate all the function calls anyway. It's just a question of which is easier to read and understand. The single call is more complex to implement but is easier to call, while the double call is easier to implement but more complex to call. However, the double call can easily be extended to a triple call for the max of 4 numbers, and so on.
#include <iostream>
int max(int x, int y )
{
return(x>y?x:y);
}
int max(int x, int y, int z )
{
return(x>y?x>z?x:z:y>z?y:z);
}
int main()
{
int x=1, y=2, z=3;
std::cout << max(x,y,z) << std::endl;
std::cout << max(max(x,y),z) << std::endl;
return( 0 );
}
int i=0,a,b,c,d;
label:
while(i == 0){
switch(1){
case 1:
if((a>b) && (a>c) && (a>d)){
printf("%d is greater",a);
i++;
goto label;
}
case 2:
if((b>c) && (b>d)){
printf("%d is greater",b);
i++;
goto label;
}
case 3:
if(c>d){
printf("%d is greater",c);
i++;
goto label;
}
case 4:
printf("%d is greater",d);
i++;
goto label;
}
}
#include <iostream.h>
class biggest
{private:
int a,b,c,big;
public:
void getdata(void);
void bigge(void);
void putdata(void);
};
void biggest :: getdata()
{
cout<<"Enter the number"
cin>>a>>b>>c;
}
void biggest :: putdata()
{
cout<<"a="<<a;
cout<<"b="<<b;
cout<<"c="<<c;
cout<<"biggest="<<big;
}
void biggest :: bigge(void)
{
if (a<b && a<c)
{big=a;
cout<<"biggest="<<big;
}
elseif(b<a && b<c)
{
big=b;
cout<<"biggest="<<big;
}
elseif (c<a && c<b)
{big=c;
cout<<"biggest ="<<big;
}
}
int main()
{
biggest b;
b.getdata();
b.bigge();
b.putdata();
return 0:
}
write a c++ program to convert binary number to decimal number by using while statement
You can use unlimited number of variables for a structure and you can also declare array of structures.
12
int i, largest=0;do { scanf ("Enter a number (0 to exit): %d", i); if (i>largest) largest=i; } while (i!=0); printf ("Largest number is: %d\n", largest);
program that take three decimal number as input and find the largest among them in assembly language
There is no limit to the number of variables.
There is no "this statement" associated with the question, but the maximum number of points which lie of the graph of a linear equation in two variables is infinite.
write a c++ program to convert binary number to decimal number by using while statement
The statement is true only if either the number is 0, or the variables are all raised to the power 0. In no other case can a variable involved.
write a c++program by using if statement to read a number and check whether it is positive or negative
You can use unlimited number of variables for a structure and you can also declare array of structures.
12
first sort the ten numbers in descending order and print the first number. That will be the largest no
The largest number of immigrants to America before 1860 came from Central and Southeastern Europe.
There are different ways of writing a pseudocode statement but the concept remains, it can be presented: /*Declare variables Total (number (3)) = 0 A (number (2)) =10 B (number (2)) =14 begin Total=A+B end
Write your own prime number program and find out.
There is no limit to the number of variables a formula can have.