+ 1
Program to input three numbers and find the largest
11 Answers
+ 13
@ Jayden LeCorps, looks good, very nice 👍😉
+ 12
@ Jayden, right solution 👍😉
+ 12
oh oh, i made a mistake:
@ Jayden, there is one little failure:
#include <iostream>
using namespace std;
int main() {
int x = 1;
int y = 3;
int z = 5;
if(x > y && x > z){
cout << x;
}
else if(y > x && y > z){
cout << y; // output y
}
else if(z > y && z > x){
cout << z;
}
return 0;
}
+ 10
@ Jayden LeCorps, but if you change z, for example: int z = 5;
your code doesn't work propper 🤔
+ 10
i think with the parenthesis you tested a boolean and with y = 2, y is bigger as the boolean (x&&z), if i am right 🤔🤔
+ 8
Hint:
- Declare an array with three elements of your desired type.
- Ask user to fill each of the elements with value.
- Have a "max" variable declared, set to zero.
- Use a loop to iterate the elements, whenever you find array[i] to be larger than "max" assign array[i] to "max".
- Best of luck : )
Hth, cmiiw
+ 7
Or is this a homework?
+ 4
homework😆
+ 3
😁😁😁
+ 3
thankyuu
0
#include<studio.h>
#include<conio.h>
void main()
{
int a,b,c;
printed("enter the value of a,b,c");
Scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("a is largest");
}else
printf("c is largest");
}else
if(b>c)
{
printf("b is largest");
}else
printf("c is largest");
getch();
}