+ 2

Int main (). { int i=20,j=10; if(I<10); I=i-5; j=j-5;printf("%d %d \n",I,j);

What is output

27th Dec 2020, 6:02 AM
Ankit Kumar
19 Answers
+ 3
Why 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
27th Dec 2020, 6:08 AM
noteve
noteve - avatar
+ 2
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!
27th Dec 2020, 6:16 AM
noteve
noteve - avatar
+ 1
Ankit Kumar, try it in the code playground please!
27th Dec 2020, 6:06 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
+ 1
20 10
27th Dec 2020, 6:08 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
+ 1
《 Nicko12 》just gave you the answer.
27th Dec 2020, 6:10 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
+ 1
If there is semicolon after "if" statement the answer will be 15 5
27th Dec 2020, 6:11 AM
Padala Vamsi
Padala Vamsi - avatar
+ 1
It is because there is semicolon at the end of "if" statement that means the statements after "if" will execute irrespective of the condition
27th Dec 2020, 6:13 AM
Padala Vamsi
Padala Vamsi - avatar
+ 1
Are you not getting 15 5?
27th Dec 2020, 6:27 AM
Padala Vamsi
Padala Vamsi - avatar
+ 1
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?
27th Dec 2020, 6:27 AM
noteve
noteve - avatar
+ 1
Yes Ankit Kumar output is clear it is 15 5. What are you expecting?
27th Dec 2020, 6:30 AM
Padala Vamsi
Padala Vamsi - avatar
0
Wrong answer not 20 10
27th Dec 2020, 6:09 AM
Ankit Kumar
0
15 5
27th Dec 2020, 6:11 AM
Ankit Kumar
0
semicolon after if statement it is null statement and excute 15 5
27th Dec 2020, 6:12 AM
Ankit Kumar
0
Write sai
27th Dec 2020, 6:13 AM
Ankit Kumar
0
Ap code kar dekh ligye
27th Dec 2020, 6:24 AM
Ankit Kumar
27th Dec 2020, 6:27 AM
noteve
noteve - avatar
0
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
27th Dec 2020, 5:45 PM
vashali gupta
vashali gupta - avatar
- 1
Any one can explain it
27th Dec 2020, 6:08 AM
Ankit Kumar