JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: C Language in hindi

Decision Making Tools : Swich or goto statement in hindi in c language स्विच और गोटू स्टेटमेंट

स्विच और गोटू स्टेटमेंट Decision Making Tools : Swich or goto statement in hindi in c language :-
जैसे-जैसे conditions बढती है वैसे वैसे if else structure की complexity बढती जाती है | और प्रोग्राम को पढना और समझना मुश्किल हो जाता है लेकिनं C language दो statements की facility दी है :-
Switch Statement :
Switch statement एक multiway decision statement है |switch statement किसी expression को check करता है उस expression के मिलने वाले constant और integer के अनुसार blocks (Group of statements) execute हो जाता है |इस struture निन्म है :-
switch(expression)
{
case value 1:
      block 1;
      break;
case value 2:
      block 2;
      break;
……………….
……………….
……………….
case value n:
   block n;
   break;
}
Statement ;
इस syntax मे expression का आउटपुट constant और integer और character हो सकता है | ये आउटपुट value 1,value 2,……………………..value n होता  है |
Break statement उस switch statement मे block को terminate करने के लिए किया जाता है |इसके अलावा default block होता है जो  expression के आउटपुट को किसी भी case value से ना मिलने पर execute होता है|
उदहारण के लिए :
#include <conio.h>
void main ()
{
int a,b,c;
float Avg;
printf(“Enter your four subject martks = /n”)  ;
scanf(“%d %d %d %d”,&a,&b,&c,&d) ;
Avg = (a+b+c+d)/4;
switch((int)Avg/10)
{
case 10:
case 9:
case 8:
printf(“Honours”);
break;
case 7:
case 6:
printf(“First division”);
break;
case 5:
printf(“Second division”);
case 4:
case 3:
printf(“Third division”);
default:
printf(“Fail”);
}
}
इस उदाहरण मे चार subject के मार्क्स के averge को Avg मे assign हो जाता है जिसका data type float है | switch मे यूज़ करने के लिए Avg को data type को type casting से integer मे convert किया जाता है |
अगर Avg की value 10,9,8 है तब  Honours होगा |
जब Avg की value 7,6 होगी तब First division होगा |
जब Avg की value 5 होगी तब Second division होगा |
जब Avg की value 3,4 होगी तब Third division होगा |
default value मे Fail message आयेगे |
आउटपुट होगा :-
Enter your four subject marks =
85 66 67 89
First division
Switch statement के rule:
1. switch expression का आउटपुट integral हो चाहिए|
2.case lable unique होने चाहिए|
3.switch statement मे केवल एक default block हो सकता है |
4.case label ऑप्शनल है |

go to Statement :

सब किसी प्रोग्राम मे किसी block (Group of Statements) को बार बार  repeat करना होता है  tab इस statement का use हो जाता है |
goto statement मे name  की जरुरत होती है name उस block का नाम है जिसे प्रोग्रामर को repeat करना है |ये statement दो प्रकार से इस्तेमाल करता है |
1.BACKWARD JUMP Looping:
अगर EXECUTION BLOCK goto statement से पहले है और condition check होने के बाद EXECUTION BLOCK repeat होता है | इसका STRUCTURE है :-
read  name :
  block statements;
  ………………………;
  ………………………;
if (condition)
goto name ;
2.FORWARD JUMP looping :
जब EXECUTION BLOCK goto statement के बाद होता है और condition पहले check होती और बाद मे EXECUTION BLOCK execute होता है |
if (condition)
goto name;
statement  ;
……………..;
read  name :
  block statements;
  ………………………;
  ………………………;
उदहारण के लिए :
इस उदहारण मे हम tabel print करायेगे|
#include <conio.h>
void main ()
{
int a=0;
int table ;
printf(“Enter your number”);
scanf(“%d”,&table)
int mul;
read code:
a=a+1;
mul=a*table;
printf(“a*table=%d”,mul);
if(a<=10)
goto code;
}
इस उदहारण मे backward jump मे होता है |जिसमे प्रोग्रामर द्वारा code block statements तब तक repeat होता है जब तक a की value 0 से 10 तक नहीं हो जाती है |
आउटपुट होगा :-
Enter your number 2
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

1 day ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

1 day ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

3 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

3 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now