This content originally appeared on DEV Community and was authored by Hrithik Gorane
whenever we heard/thought about conditional we can relate easily because it's part of our life. how, suppose you have two car one car fuel is petrol and second car fuel is diesel. now you're first car fuel is empty then you will drive second car correct because here first's car fuel is empty therefore you chosen second car.
if you're first car has fuel then you can not choose second you go with you're first car right. similarly in computer we used these kind of conditions with deal and handle the case and solve the problem easily.in computer these case we used if else term. if term we put condition and else part we simply showcase if condition not satisfied. here below if else condition syntax,
if(condition){
statement :
}else{
statement :
}
ex, if(mark > 33){
statement : pass
}else{
statement : fail
}
above example we can easily understand that if student get marks above 33 then he pass or student is fail.
if you have multiple condition then you can use else if condition where it known as ladder condition.
here below syntax,
if(condition){
statement :
}else if(condition){
statement :
}else{
statement :
}
here how we know about conditional. keep practice, remember we are in community where you can ask it and you get answer that ask for it.
This content originally appeared on DEV Community and was authored by Hrithik Gorane
Hrithik Gorane | Sciencx (2024-10-06T03:12:58+00:00) …conditional…. Retrieved from https://www.scien.cx/2024/10/06/conditional/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.