+ 1

Why i am not able to get right output

#include<stdio.h> //#include<conio.h> #include<math.h> int main() { int a,b; printf("\n enter no.1st n 2nd"); scanf("%d &d",&a,&b); if(a==b) printf("error"); else{ if(a>b) printf("largest no=%d",a); else printf("largest no=%d",b); } getch(); }

3rd Sep 2017, 10:22 AM
GANESH CHAVHAN
GANESH CHAVHAN - avatar
2 ответов
+ 2
First : scanf doesn't work on sololearn Second : correct from "%d &d" to "%d %d" in scanf Third : getch used with commented conio header Fourth : no return statement
3rd Sep 2017, 10:42 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 8
Did you run this code on Code Playground? Try this version: #include <iostream> int main() { int a,b; std::cin >> a >> b; if(a==b) std::cout << "Error"; else std::cout << "Largest = " << (a > b ? a : b); return 0; }
3rd Sep 2017, 10:32 AM
Hatsy Rei
Hatsy Rei - avatar