+ 1

Program to input three numbers and find the largest

21st Feb 2018, 2:40 AM
rosemary
11 Réponses
+ 13
@ Jayden LeCorps, looks good, very nice 👍😉
21st Feb 2018, 5:36 AM
tooselfish
tooselfish - avatar
+ 12
@ Jayden, right solution 👍😉
21st Feb 2018, 6:01 AM
tooselfish
tooselfish - avatar
+ 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; }
21st Feb 2018, 6:49 AM
tooselfish
tooselfish - avatar
+ 10
@ Jayden LeCorps, but if you change z, for example: int z = 5; your code doesn't work propper 🤔
21st Feb 2018, 5:49 AM
tooselfish
tooselfish - avatar
+ 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 🤔🤔
21st Feb 2018, 5:55 AM
tooselfish
tooselfish - avatar
+ 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
21st Feb 2018, 5:58 AM
Ipang
+ 7
Or is this a homework?
21st Feb 2018, 3:00 AM
DAB
DAB - avatar
+ 4
homework😆
21st Feb 2018, 3:02 AM
rosemary
+ 3
😁😁😁
21st Feb 2018, 6:44 AM
rosemary
+ 3
thankyuu
21st Feb 2018, 6:44 AM
rosemary
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(); }
15th Mar 2018, 12:25 AM
Deepak chaurasiya
Deepak chaurasiya - avatar