Can anyone plz describe me about if statement i still didn't understand about this....???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone plz describe me about if statement i still didn't understand about this....????

Can anyone plz describe me about if statement i still didn't understand about this....????

23rd Apr 2017, 11:31 AM
Zuraiz Javaid
Zuraiz Javaid - avatar
5 Answers
+ 2
If statements are to help programs skip lines if certain conditions are met where you want to jump over a section of code. Think about reading sentences. You go to the club and are asked to provide your age. If (age >= 21) say "Come on in." User_Is_In_Club = true else say "Your not old enough." User_Is_In_Club = false You dont want your program to say both lines because you will confuse people. Come on in. Your not old enough. So if statements will execute the section with the correct conditions and proceed to the rest of the code after the ending else section. If (User_Is_In_Club == true)// (User_Is_In_Club) will produce the same results. Users_Mood = "Happy" else Users_Mood = "Sad" Now we can use a cout statement. cout << Users_Mood; // We will be able to monitor the users Mood status though the use of if statements with out making the user Happy and Sad.
23rd Apr 2017, 4:55 PM
Ty Ler
Ty Ler - avatar
+ 8
You got to yourself into a lottery, and all you have to do is throw a die, IF you get 6 you win ELSE you lose. Heres a program if(dieCount==6) win else lose I hope its clear.
23rd Apr 2017, 11:36 AM
Meharban Singh
Meharban Singh - avatar
+ 1
yup not completely but little bit n thanks for your help bro
23rd Apr 2017, 11:38 AM
Zuraiz Javaid
Zuraiz Javaid - avatar
+ 1
got it thanks bro
29th Jul 2017, 11:35 AM
Zuraiz Javaid
Zuraiz Javaid - avatar
0
if(condition) { //this part executes if condition is true } else {//this part executes if condition is false } for example if(a==10) { cout<<"ten"; } else { cout<<"other number"; } in this if value of a is 10 then it print ten otherwise it print other number
23rd Apr 2017, 11:38 AM
Mayur Chaudhari
Mayur Chaudhari - avatar