Monday, 20 July 2020

What are conditional statements in programming ? and what are the uses of these conditional statements in a programm ?

What are conditional statements in programming ? and what are the uses of these conditional statements in a programm ?


Conditional statements in a program are use to check the applicable statement in the program to make the calculation easy and optimized in our program 


Also these conditional statements helps a programmer to solve the complex problems easily in our program 


Below mentioned some conditional statements are often used in our program :- 


  1. If statement :- 

Syntax - if (condition) { code block } 


Hear in the if statement we check one condition in our program if the condition given by the user is satisfied then it print some statement in the program 


  1. If else statement :- 

Syntax - if (condition) { code block }

                else { code block }


Hear in the if else statement we check one condition in our program if the condition given by the user is satisfied then it print some statement and if the condition in the program doesn’t satisfies then it prints some other statement in the program 


  1. Else if statement :- 

syntax - if (condition 1) { code block }

              else if (condition 2) { code block }

               else { code block }


Hear in the else if statement we can check two or more than two conditions in our program and return a desirable value through our program


  • Ternary operator :- 


Ternary operators are used as a shorthand operators of if-else statement in our program 

as we have seen that it is shorthand operators of if else statement so the implementation of ternary operator is same as if else statement 


Syntax - variable = ( condition ) ? expression true ; expression false ;


  • Conditional operators :-

 

Conditional operators in a program are used to check some conditions in the program 


below some of the conditional operators are given :- 


== , != , > ,< ,>= ,<= ,etc


BY :- ADARSH GUPTA 

No comments:

Post a Comment

Linking Words/ Conjunctions

  Linking Words/ Conjunctions Conjunctions are words that link other words, phrases, or clauses together. Kinds of conjunctions Conjunctions...