C Switch Case Statement

c switch case in c in hindiDear Students, aaj ke is Lecture me hum c switch case ke bare main padege. Yani ke c language mian switch case kya hote hai. C language mian switch case kaise kaam karte hai. Types of conditional statements in c aadi se related ye sare topic ham is lecture main cover karege.

Lectures Covering Topics

  • Introduction To C Switch Case In Hindi
  • What Is Use C Switch Case In Hindi
  • Rules for switch statement in C language
  • What Is Syntax of C Switch Case In Hindi
  • Flow Chart Of C Switch Case Statements In Hindi
  • Example Of C Switch Case In Hindi
  • How To Work Switch Case In C Language In Hindi

C switch case statements Control statements ka he part hai. Control statements yani ki ese statements jo poore program ko control karte hai. Jab programmer user ke input par depend hota hai tab programmer control statements ka use karta hai.

Introduction To C Switch Case – Switch Case Kya hote hai In Hindi 

To students isse previous lecture me mene aapko if statements ke bare me bataya tha. Theekh usi tarah see c switch case statements bhi work karta hai. C switch case statements ko samjhna bahut he simple hai. jaise ke mene aapko bataya hai ki program ko control karne ke liye switch case statements ka use karte hai.

C language main agar kisi statement ka use kisi condition ke base par kiya jata hai tab c switch case statements ka use kiya jata hai. Switch case ko conditional statement bhi kahte hai.

Dekho jab hame sirf eak ya kuch limited condition deni hoti hai. To ham if else if statements ka use kar lete hai. But jab hame bahtu sari condition eak he statements me apply karni hoti hai to hum switch case statements ka use karte hai.

What Is Use C Switch Case In Hindi

Jab hum program me eak sath bahut sare if condition ka use karte hai. To program kafee bada or lengthy ho jata hai. Is bajah se program padna or samjhna kafee mushkil ho jata hai. Is problem se bachne  ke liye hum switch case statements ka use karte hai.

To Jab hame eak se jayada condition ke eak sath apply karna hota hai. Tab ham switch case statements ka use karte hai. Jis tarah se if condition eak tow way condition statements hai. Usi tarah switch eak multi way condition statements hai.

Yah bilkul if else if else ki tarah se kaam karta hai. Hum isme eak expression ke sath bahut sare values ko eak sath compare kara sakte hai. Isme sare values case ke roop me compare karne ke liye define ke jati hai.

Rules for switch statement in C language

  • Switch expression hamesha integer ya character data type ki he honi chahiye.
  • Case main hamesa character or integer ki value constant honi chahiye.
  • Case ke value ko keval switch statements ke andar he use kiya ja sakta hai.
  • C Switch case mian break statements use krna jaroori nahi hota hai. Yah optional hota hai. Yadi switch case main koi statements nahi milta hai. To sare cases case value se match hone ke bad bhi execute hote hai. Ise c language mian c switch case ka fall through statement mana jata hai.

What Is Syntax of C Switch Case In Hindi

Switch case statements ka syntax neeche likha hua hai.

Flow Chart Of C Switch Case Statements In Hindi

Aap switch case statements ko neeche flow chart ke help se bhi samjh sakte hai. Yahn par poora eak switch case statements ka flow chart banaya gya hai.

c switch case flow chart in hindi

 

Example Of C Switch Case In Hindi

Yahn par aap switch case ko eak example ko lekar bhi samjh sakte hai. neeche likhe huye example ko aap pane compiler par type karke run kara sakte hai.

First without use break statements 

Output

c switch case example without break statements

Second use with break statements 

Output

c switch case example with break statements

How To Work Switch Case In C Language In Hindi

Switch case statements ke execution ke liye sabse pahle variable ya expression ki value ke tulna (compare) eak eak karke sabhe cases ke ki jati hai. Or jhan bhi value mil jati hai uske statements ko execute kiya jata hai. Sabhi statements ke bad agr break statement lga hota hai to switch ko vahi break kar diya jata hai.

Yadi break statement nahi likha hota hai to value milne ke bad sabhi cases execute hote hai.  Jab tak switch case ko break statements nahi mil jat hai tab tak vah apne sare statement execute karta hai.

Switch case statements main di gayi default case label eak optional label hai. Yadi yah switch statements main hot hai. Or expression ya variable main diye gaye maan (value) switch statements me diye gaye kisi bhi case statements se match nahi karti hai. To Program control default case label ko execute karta hai. Jab tak ise bhi koi break statements nahi milta to ye bhi apne sabhi statements execute karta hai.

Related Lecture

Dear Students, main aasha karta hun ki aapko c switch case statements Ka Lecture padh kar samjh me aa gaya hoga. Ki C language main switch case ka use kaise karte hai. Yadi aapako is lecture se related koi bhi problem hai to aap hume comment karke puch skte hai.

Share This Post On

About Author

Thakur Aman Singh

Hey, I am Aman Singh Tomar from Taj City Agra. Through This Blog I want to share my Knowledge with all of you. Read More >>

Leave a Reply

Your email address will not be published. Required fields are marked *