21 Answers
New Answer12/27/2020 6:02:16 AM
Ankit Kumar21 Answers
New AnswerWhy not try it? By the way there are some error I found like semicolons in " if " condition and some uppercases. https://code.sololearn.com/cA10A157A5A1
Ankit Kumar OK I know where you are getting into. You expect the output to be 15 5 right? Then it is because the if statement is False - - - - - - - - - - - - - - - i = 20 if (i < 10) - - -> This is False - - - - - - - - - - - - - Therefore the code below it will not be executed and the value of both i and j will not be substracted by 5. Make the value of i less than 10 to make it happen. I hope you now get it. Happy Coding!
It is because there is semicolon at the end of "if" statement that means the statements after "if" will execute irrespective of the condition
sai vamsi Yeah I also got 15 5 But in my first code it outputs 20 10 cause the if-statement is False and did not substract the numbers so... Ankit Kumar What output do you want anyway?
Ankit Kumar Here output will be different. https://code.sololearn.com/cx6eHpQWM8nr/?ref=app
int main() { int i=20,j=10; if(i<10);---->semicolon means termination so this condition will not be considered . i=i-5;//i=15 j=j-5;//j=5 printf("%d%d",i,j); hence output will be 15,5
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message