if(condition1){// block of code to be executed if condition1 is true}elseif(condition2){// block of code to be executed if the condition1 is false and condition2 is true}else{// block of code to be executed if the condition1 is false and condition2 is false}
const randomObject =5;if(randomObject <2){console.log("The Random Object has a value more than 2");}else{console.log("The Random Object has a value less than 2");}
int age =30;if(age >=30&& age <=80){System.out.println("Old");}elseif(age <30&&>=1){System.out.println("Young");}else{System.out.println("Not Supported");}
const count =20;if(count ===0){console.log('There are no students');}elseif(count ===1){console.log('There is only one student');}else{console.log(`There are ${count} students`);}
const number =(Math.random()-2.5)*5;if(number <0){console.log('Number is negative');}if(number =0){console.log('Number is zero');}if(number >0){console.log('Number is positive');}
//An if statement can be followed ba an optional else statement, which //executes whe the Boolean expression is falseif(Boolean_expression){// Executes when the Boolean expression is true}else{// Executes when the Boolean expression is false}
var a =prompt("value 1")var b =prompt("value 2")var c =prompt("value 3")var d =prompt("value 4")var e =prompt("value 5")if(a >= b && a >= c && a >= d && a >= e){console.log(a +" this is greater value")}elseif(b >= a && b >= c && b >= d && b >= e){console.log(b +" this is greater value")}elseif(c >= a && c >= b && c >= d && c >= e){console.log(c +" this is greater value")}elseif(d >= a && d >= b && d >= c && d >= e ){console.log(d +" this is greater value")}elseif(e >= a && e >= b && e >= c && e >= d){console.log(e +" this is greater value")}else{"enter the valid number"}
var condition =true;// An example condition for true/false conditionsif(condition ==true){console.log('condition is true');}else{console.log('condition is not true');}// Console will output 'condition is true'
var age =prompt("enter your age")if(age>=60){console.log("you are older")}elseif(age >=18){console.log("you are adult")}elseif(age <18){console.log("you are child")}
>> number=23>> guess =input('Enter a number : ')>>if guess == number:>>print('Congratulations! You guessed it.')>> elif guess < number:**(It is giving me 'Invalid Syntax')**>>else:**(It is also giving me 'Invalid syntax')**
if(condition){//action to take if condition is met}elseif(condition){//action to take if first condition is not met but there is a second condition}else{//actioon to take if all conditions are not met}
if(condition1){//runs if the condition is true//type what you want to happen if the condition is true}elseif(condition2){//type what you want to happen if the condition is true}else{//If no condition is true it will run this//type what you want it to do}
using System;classNumbersNotDivisibleBy3And7{staticvoidMain(){
Console.WriteLine("Enter an integer:");
int n = int.Parse(Console.ReadLine());for(int i =1; i <= n; i++){if(i %3!=0&& i %7!=0){
Console.Write("{0} ", i);}}
Console.WriteLine();}}
var a =prompt("Enter s for squareEnter t for triangle")if(a=="s", a=="S"){var side =prompt("enter the value")var b = side *side;console.log(b,"this is square area")}elseif(a=="t", a=="T"){var base =prompt("enter the base value")// base = 1/2;var height =prompt("enter the height")
area=1/2*base*height;console.log(area,"this is the area of triangle")}else{console.log("invalid input")};