If Else If Statement In C++ With Example

If Else If Statement In C++ With Example:

If Else If Statement In C++ With Example

C या C++ Language हमें जब भी ऐसी किसी Condition को Check करना होता हैं जिसके हमारे पास दो या दो से अधिक Options होते हैं तो हम वहाँ पर If Else Statement का Use करते हैं। जैसे हम दो Variables में Value Input कर Check करना चाहते हैं कि किस Variable में Value अधिक हैं तो हम वहाँ पर Condition को कुछ इस तरह लिखेंगे।

Syntex –

if (Condition)

      Statement 1;

else

  Statement 2;

Example- 

if (a>b)

   cout<<“Print A”;

else

   cout<<“Print B” ;

अगर इस Condition में a की Value ज्यादा होगी तो कंप्यूटर Print कर देगा “Print A”। लेकिन अगर Condition गलत होगी तो “Print B” , Screen पर Print हो जायेगा । Else Statement के बाद भी जरूरत पड़ने पर If Else Statement का Use किया जा सकता हैं।

syntex –

if (Condition )

    {

         if (Condition )

         Statement 1;

         else

        Statement 2;

}

else

if (Condition )

         Statement 1 ;

         else

        Statement 2 ;

If Else Statement को आप नीचे दिये दोनों Example से आराम से समझ सकते हैं। Five Numbers में Largest Value    Find Out करने के लिए Largest Value of Any Five Numbers  में Click करें। 

Find Out The Largest Value of Any Three Numbers. 

If Else If Statement In C++ With Example In Hindi

Example 1.

#include<iostream.h>

#include<conio.h>

void main()

{

int a , b , c ;

clrscr() ;

cout <<“Enter Three Numbers    ” ;

cin>>a >>b>>c ;

If (a>b)

{

If (a>c)

cout <<“The Largest Value is A     =  “<<a ;

else

cout <<“The Largest Value is  C    =  “<<c ;

}

else

If (b>c)

cout <<“The Largest Value is B     =  “<<b ;

else

cout <<“The Largest Value is  C   =  “<<c ;

getch() ;

}

Example 2.

Find Out The Largest Value of Any Four Numbers.

Find Out The Largest Value of Any Four Numbers.

#include<iostream.h>

#include<conio.h>

void main()

{

int a , b , c , d ;

clrscr() ;

cout <<“Enter Four Numbers    ” ;

cin>>a >>b>>c>>d ;

If (a>b)

{

If (a>c)

{

if(a>d)

cout <<“The Largest Value is A ” ;

else

cout <<“The Largest Value is  D” ;

}

else

if(c>d)

cout <<“The Largest Value is C ” ;

else

cout <<“The Largest Value is  D” ;

}

else

{

If (b>c)

{

if(b>d)

cout <<“The Largest Value is B” ;

else

cout <<“The Largest Value is  D ” ;

}

else

if(c>d)

cout <<“The Largest Value is C ” ;

else

cout <<“The Largest Value is  D “;

}

getch() ;

If Else Statement In C Programming In Hindi ,

Find Out the Largest Value of any given Five Numbers in C.

इसी Post से संबंधित “If Else Statement In C” , Video को हमारे YouTube channel  में देखने के लिए इस Link में Click करें  ।   YouTube channel link –  (Padhai Ki Batein /  पढाई की बातें)

NOTE – Class 8th , 9th , 10th , 11th , 12th के हिन्दी विषय के सभी Chapters से संबंधित videos हमारे YouTube channel(Padhai Ki Batein /  पढाई की बातें) पर भी उपलब्ध हैं। कृपया एक बार अवश्य हमारे YouTube channel पर visit करें । सहयोग के लिए आपका बहुत – बहुत धन्यबाद।

You are most welcome to share your comments . If you like this post . Then please share it . Thanks for Reading.

यह भी पढ़ें

  1. C और C++ क्या हैं ?
  2. C या C++ में पहला Program कैसे बनाते हैं ?
  3. Difference Between If And If Else Statement In C
  4. 6 Small And Simple Programs For Beginners
  5. If And If Else Statement
  6. Find Out the Largest Value of any given four And Three Numbers in C.
  7. What is HTML Coding
  8. Web Page कैसे बनाते हैं
  9. HTML Form 
  10. How To Create Table In Html
  11. How To Create Hyperlink In HTML
  12. How To Insert An Image In HTML Page
  13. Ordered And Unordered List In HTML
  14. Frame In HTML Coding
  15. Add Background Color And Image
  16. Map in HTML
  17. Nested List In HTML
  18. How To Create A Website Using HTML Only On Notepad No CSS Used
  19. How TO Create A Beautiful And Simple WebPage Using HTML Only (No CSS Used)