0
How to use if-then-else statement?
13 Antworten
+ 4
Yash Kishore the code you posted is in BASIC language, not C++.
+ 3
We need to use `==` operator to compare two objects while `=` is used for assigning values.
+ 2
In wich language are you programming?
+ 2
Sorry, I have been afk for the last hour
But have you tried this?
I'm not a pro in C++ but on my Sololearn it works if I do it like this:
if (a = 18) {
//your code b
} else {
//your code c
}
+ 2
Ah sorry, of course you're right. Otherwise it won't return a boolean value of course
+ 1
C++
+ 1
okay. Do you have an example of code where it didn't work? Maybe we can find the mistake here
+ 1
Input "your age";a
If a = 18 then goto b else goto c
+ 1
OK thanks
+ 1
if (condition 1) {
// code block 1
}
else if (condition 2){
// code block 2
}
else {
// code block 3
}
Here:-
If condition1 evaluates to true,
the code block 1 is executed.
If condition1 evaluates to false, then condition2 is evaluated.
If condition2 is true, the code block 2 is executed.
If condition2 is false, the code block 3 is executed.
+ 1
if(boolean statements) {
body}
else{
body}
0
OK bro
0
age = 18
if(age):
print("You're 18")
else:
print("You're not 18")