जब हमें बयानों के एक खंड को निष्पादित करने की आवश्यकता होती है, जब किसी दी गई स्थिति सही होती है तो हम बयान का उपयोग करते हैं। अगले ट्यूटोरियल में, हम C if..else, नेस्टेड if..else और अन्य..आईएफ सीखेंगे।

Variable x is less than y
enter the value of x:20
enter the value of y:20
x is equal to y
End of Program
यदि एक से अधिक शर्तों की जांच करने के लिए हम कई का उपयोग कर सकते हैं।
![]() |
c programing language in hindi |
सी - अगर बयान (C – If statement)
यदि कथन का सिंटैक्स:
दिए गए शर्त के सही होने पर "यदि" केवल तभी लागू होता है, जब "अगर" का विवरण दिया जाए। यदि स्थिति झूठी है, तो "यदि" के अंदर दिए गए कथनों को छोड़ दिया जाता है।if (condition) { //Block of C statements here //These statements will only execute if the condition is true }
Flow Diagram of if statement

Example of if statement
#include <stdio.h> int main() { int x = 20; int y = 22; if (x<y) { printf("Variable x is less than y"); } return 0; }
Output:Variable x is less than y
स्पष्टीकरण: "यदि" में निर्दिष्ट शर्त (x <y) x और y के मान के लिए सही है, तो यदि निष्पादित किया गया है तो शरीर के अंदर का विवरण।
कई उदाहरणों का कथन है (Example of multiple if statements)
#include <stdio.h> int main() { int x, y; printf("enter the value of x:"); scanf("%d", &x); printf("enter the value of y:"); scanf("%d", &y); if (x>y) { printf("x is greater than y\n"); } if (x<y) { printf("x is less than y\n"); } if (x==y) { printf("x is equal to y\n"); } printf("End of Program"); return 0; }
Output:enter the value of x:20
enter the value of y:20
x is equal to y
End of Program
यदि एक से अधिक शर्तों की जांच करने के लिए हम कई का उपयोग कर सकते हैं।
0 Comments:
Post a Comment