JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: C Language in hindi

Decision Making – If Statement in hindi in c language इफ स्टेटमेंट c कंप्यूटर भाषा में

इफ स्टेटमेंट c कंप्यूटर भाषा में Decision Making – If Statement in hindi in c language :-
C Program दो या दो से अधिक statements का  समूह होता है जो sequence से execute होता है |लेकिन कभी कभी प्रोग्रामर को किसी statements को बार बार repeat करना पड़ सकता है या प्रोग्राम के sequenceको change करना पड़ सकता है | इस तरह के operations के लिए C language मे 4 OPTION है |
1. if Statements
2.Switch Statement
3.Conditional Operator Statement
4.Goto Statement


इस article मे if statement को उदहारण के साथ पड़ेगे |if Statement का Usage:
if Statement C language मे सबसे महत्वपूर्ण decision statement है |इससे दो प्रकार के आउटपुट मिलते है |(i) true (ii)false.इसका syntax निम्न है :-

if (condition);

ये कंप्यूटर को पहले condition check करवाता है, बाद मे true और false के हिसाब से satement पर control करता है |

ये चार प्रकार के होते है :-

1.Simple if Statement

Simple if statement मे,अगर condition true होती है तब true statement block execute होता है और false होने पर ,true statement block के बाद वाले Statements execute होते है |इसका structure है :-

if(condition)
{
true statements block ;
}
statements ;

 

उदहारण के लिए :
#include <conio.h>
void main ()
{
int a,b;
printf(“Enter first input”);
scanf(“%d”,&a);
printf(“Enter second input”);
scanf(“%d”,&b);
if (a<b)
{
printf(“%d is bigger than %d .  “,a,b)
}
printf(“%d is bigger than %d .”,b,a)
}


इस उदहारण मे condition सही होने पर a is bigger than b. print होगा और गलत होने पर  b is bigger than a . print होगा |


आउटपुट होगा :-
Enter first input 567
Enter second input 614
614 is bigger than 567 .
और
Enter first input 97
Enter second input 67
97 is bigger than 67 .

if-else Statement :


इस प्रकार मे प्रोग्रामर दो blocks (Group of Statements) बना सकता है एक condition True होने पर execute होगा और दूसरा  condition false होने पर execute होगा |इसका structure निम्न है :-
if (condition)
{
true condition block ;
}
else
{
false condition block;
}
statement ;

उदहारण के लिए :

#include <conio.h>
void main ()
{
int a,b,c;
printf(“Enter first input”);
scanf(“%d”,&a);
printf(“Enter second input”);
scanf(“%d”,&b);
if (a<b)
{
c=b/a;
printf(” output of b/a = %d “,c);
}
else
{
c=a/b;
printf(“output of a/b =%d”,c);
}
printf(“a is same b.”);
}
}
Output होगा :
Enter first input 555
Enter second input 5
output of a/b =111
और
Enter first input 2
Enter second input 666
output of b/a =333
और
Enter first input 235
Enter second input 235
a is same b.

Nested If Else Statement
 जब एक या एक से अधिक  decisions /conditions को check करना हो तब nested if else statement का इस्तेमाल होता है | इसका Structure निन्म है :-
if (condition -1)
{
if ( condition-2)

   {
       True Statement block for if condition-2
   }
Else
   {
      False staement block for if condition-2
   }
}
else 
{
False statements block for if condition-1
}

इस structure मे जब condition-1 गलत होगी तब False statements block for if condition-1 execute होगा |और true होने पर if statement चलेगे जो condition-2 check करेगा |


उदहारण के लिए:
नीचे दिया गया उदहारण मे ,तीन numbers मे से सबसे बड़ी numbers को find करना है जिसमे nested if statement को इस्तेमाल किया गया है |

#include<conio.h>
void main()
{
int a,b,c;
printf(“Enter first input”);
scanf(“%d”,&a);
printf(“Enter second input”);
scanf(“%d”,&b);
printf(“Enter third input”);
scanf(“%d”,&c);
if (a>b)
{
if (a>c)
{
prinf(“\n%d is bigger among them.”,a);
}
else
{
printf(“\n%d is bigger among them.”,c);
}
else
{
if (b>c)
{
printf(“\n%d is bigger among them.”,b);
}
else
printf(“\n%d is bigger among them. “,c);
}
}

इस उदहारण मे,सबसे पहले a का comparison b और c से होता है |सबसे पहले a को b से compare करते है a को  बड़ा होगा तब दुसरे if statement मे  b से compare होगा और true होने पर a is bigger among them. प्रिंट होगा |
पहले if statement मे false होने पर b को c से compare होता है , अगर b बड़ा है तब b is bigger among them. प्रिंट होगा और गलत होने पर c is bigger among them. होगा |

आउटपुट होगा :-

Enter first input 67
Enter second input 95
Enter third input 106

106 is bigger among them.

Else -if Statement

इस structure मे सभी else के साथ एक if statement जुड़ा होता है |इसे else if ladder भी कहते है |उदहारण के लिए :

नीचे दिया गया प्रोग्राम मे ,स्टूडेंट्स के द्वारा दिए गये मार्क्स से चार grade “honours”,”first”,”second” और ”third’ का पता लगाने के लिए है |
#include <conio.h>
void main ()
{
int a,b,c;
printf(“Enter your score”);
scanf(“%d”,&a);
if (a=>80)
{
printf(“Your Grade is honour ! congratulation.”);
}
else if(a=>60)
{
printf(“Your Grade is first division ! congratulation.”);
}
else if (a=>50)
{
printf(“Your Grade is second division ! congratulation.”);

}
else
{

printf(“Your Grade is third division ! congratulation.”);

}
}

आउटपुट होगा :-
Enter your score 67
Your Grade is first division ! congratulation.

Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

5 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

7 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

7 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

7 days 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