Decision Making in C in Hindi – C in Hindi

इस Article में हम Decision Making in C in Hindi को जानेगे। Programming में Decision Making का काफी Use है, जब हम कोई Program बनाते है, तो उसमे एक से अधिक Task करते है, किस Time कौन-सा Task Run कराना है, ये Decide करने के लिए Decision Making Statement का Use किया जाता है।
Decision Making in C in Hindi
Decision Making Statement के Programming में कौन – कौन से Use हो सकते है। इसके कुछ पहले Idea Share कर रहा हूँ।
1. किसी Program में अगर हम Input में Name ले रहे है। तो एक Condition लगानी होगी की Enter की गयी Value String में होनी चाहिए। यदि वो Integer या Float है तो Error Show हो या तो नहीं।
2. अगर Voting का Program बना रहे है। तो Condition होगी अगर Age 18 के ऊपर है। तभी वो Voting के लिए Eligible होगा। अन्यथा नहीं होगा।
तो ऐसी बहुत सी Condition Create होती है, जो हम Decision Making Statement के द्वारा कर सकते है । अब जानते है, Decision Making Statement कितने प्रकार के होते है।
1. If Statement
2. If. else Statement
3. If else Ladder Statement
4. Nested If Statement
5. Switch Statement
6. Nested Switch Statement
1. If Statement in Hindi
If Statement सिर्फ Single Condition पे काम करता है। अगर Condition True होती है। तब If Statement Block Run होता है।
Syntax of If Statement in Hindi
if (condition){ //code to be Executed }
ये इसका Syntax है। अब इसका एक Simple Example देखते है।
#include<stdio.h> #include<conio.h> int main() { int x = 10; if(x<12) { printf("Hello World"); } }
ये एक Simple Example है।
2. If Else Statement in Hindi
Syntax of If else Statement in Hindi
if(condition) { //code to be Executed } else (condition) { //code to be Executed }
अब इसका Example देखते है।
int main() { int x = 10; int y = 12; if (x<y) { printf("x is less than y"); } else { printf("y is Greater than x"); } return 0; getch(); }
If else if Ladder Statement in Hindi
Syntax of If else if Ladder Statement in Hindi
if (condition) { //Code to be Executed } else if (condition) { //code to be executed } else { //code to be executed }
1. अब देखिये इसमें सभी में Condition लगी हुई है। जो भी Condition सही होगी उसी का Code Run होगा।
Nested If Statement in Hindi
Syntax of Nested If Statement in Hindi
if (condition1) { // Code to be Executed if (condition2) { // Code to be Executed } }
5. Switch Statement in Hindi
Syntax of Switch Statement in Hindi
switch(expression) {
case 1:
//code to be executed
break;
case 2:
//code to be executed
break;
/* you can have any number of case statements */
default :
//code to be executed
}
Nested Switch Statement in Hindi
Syntax of Nested Switch Statement in Hindi
switch(expression) { // code to be executed; case 1:
// Nested switch
switch(expression)
{
// code to be executed
case 2:
// code to be executed
break;
// code to be executed
case 3:
// code to be executed
break;
// code to be executed
case 4:
statement 3;
break;
// code to be executed
default:
}
break;
// code to be executed;
case 2:
// code to be executed
break;
default:
// code to be executed
}