+ 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(); }
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
+ 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;
}