Whats wrong with my code, and how do i make it work, help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Whats wrong with my code, and how do i make it work, help

#include <iostream> using namespace std; int main() { int a,b,n; int sum; cin>>a>>b; n=a/b; sum=b*n; if(a>b){ cout<<"A is bigger than B"<<endl; if(a>sum){ cout<<"A is bigger than B more than:"<<n<<"times!"; } } else { cout<<"B is bigger than A"; return 0; } }

8th Mar 2017, 2:57 PM
Marko
Marko - avatar
2 Answers
+ 3
Nvm, found a mistake, problem was in a>sum, should have been a>=sum lol
8th Mar 2017, 3:00 PM
Marko
Marko - avatar
+ 2
You could leave the second If statement (if(a>sum)) away, cause it is not really useful, just write both cout parts in the same if statement!
2nd Feb 2018, 11:29 PM
Rambo Schweiz
Rambo Schweiz - avatar