0
How do i write multiple if-statements?
3 Answers
+ 4
if(){
code}
else(){code
}
else if(){
code}
else if(){
code}................and so on
+ 1
Using nested statement..!
0
I am new to programming. This is my 3rd week and I am beginning to find this difficult. I am nevertheless persistent. So, I've tried this in the prompt (excuse my poor knowledge of the terms);
a = 72
b = 25
c = 02
#now using this statement, I should have been able to string all three variables using the if statement in the suggested format. Now, as far as I know, it should look like;
if(a > 7){puts "Yes"}
else(b > 4){puts "Yes"}
else( c != 2){puts "Yes"}
end
#now I get;
..\Playground\:7: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
{puts "Yes"}else
^
..\Playground\:7: syntax error, unexpected '}', expecting keyword_end
{puts "Yes"}else
^
..\Playground\:9: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
{puts "Yes"}else
^
..\Playground\:9: syntax error, unexpected '}', expecting keyword_end
{puts "Yes"}else
^
..\Playground\:11: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
{puts "Yes"}
^
..\Playground\:11: syntax error, unexpected '}', expecting keyword_end
I'm gonna be honest; I don't know what this means. I've gotten many failure results but didn't understand how to read the error messages.
Help?