[solved] Simple syntax | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[solved] Simple syntax

Just wondering if it processes by Oder or if it will try to display all satisfied conditions The example that was used in the tutorial was using x>5 and a string then x>8 and a string But the int that was placed in there was a 7 so if it was a 9 would it display both outputs? Or just the last satisfied? As in will it show the string from x>5 and x>8 or would it just show the x>8? Or even just trowe an errror because there is more than one answer to thhe question Edit: I understand that in an ideal situation you should have some sort of logic behind it to make sure that there is a better choosing method but in this case I am just cuious

2nd Jul 2018, 6:31 AM
Skyler Davenport
Skyler Davenport - avatar
4 Answers
+ 4
go through this code, you'll get to know what happens , use different values of a, and different conditions. https://code.sololearn.com/cBZ2LSbVadHR/?ref=app
2nd Jul 2018, 6:38 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 2
you must know program executes sequentially until unless you have changed the control of the program to any other location. In case when you have multiple if statements ( which also transfers the control) , it starts executing from your first if-condition , if it is found to be true then the block will execute and rest other blocks ( rest if-condition and else block) will be skipped , irrespective of their condition being True or False. so you'll get the execution of the first block for which your condition satisfies, and rest block will be skipped. hope this solves your confusion.
2nd Jul 2018, 6:55 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 1
it's good to think like you did just now, but suggest you 1 more thing, try to implement these kind of doubts once by your own, sometimes you'll get to know so may interesting things, which no text can tell you. It's all about practice.
2nd Jul 2018, 7:01 AM
Nikhil Dhama
Nikhil Dhama - avatar
0
yeah that is the answer i was looking for, more or lesss was just wondering how the program itself would recognize
2nd Jul 2018, 6:57 AM
Skyler Davenport
Skyler Davenport - avatar