Control Structure in C++ (C++ में कंट्रोल स्ट्रक्चर)
A control structure is a statement or group of statements used to control the flow of execution in a program. It organizes instructions into logical units and determines the order in which they are executed.
Control Structure एक ऐसा स्टेटमेंट या स्टेटमेंट्स का समूह है जिसका प्रयोग प्रोग्राम के Execution Flow को नियंत्रित करने के लिए किया जाता है। यह Instructions को Logical Units में व्यवस्थित करता है तथा यह निर्धारित करता है कि प्रोग्राम में स्टेटमेंट्स किस क्रम में Execute होंगे।
Types of Control Structures (कंट्रोल स्ट्रक्चर के प्रकार)
Control structures are classified into three main categories:
कंट्रोल स्ट्रक्चर को मुख्यतः तीन प्रकारों में वर्गीकृत किया जाता है:
Sequential Structure (सीक्वेंशियल स्ट्रक्चर)
Selection Structure (सिलेक्शन स्ट्रक्चर)
Iterative Structure (इटरेटिव स्ट्रक्चर)
1) Sequential Structure (सीक्वेंशियल स्ट्रक्चर)
In a sequential structure, statements are executed one after another in the specified order. The program follows the sequence of instructions without skipping or repeating any statement.
सीक्वेंशियल स्ट्रक्चर में स्टेटमेंट्स को निर्धारित क्रम में एक के बाद एक Execute किया जाता है। इसमें प्रोग्राम Instructions के क्रम का पालन करता है तथा सामान्यतः किसी स्टेटमेंट को Skip या Repeat नहीं करता।
Example: Simple Interest Program
Flow of Execution:
Start → Input Principal, Rate and Time → Calculate Simple Interest → Display Result → Stop
2) Selection Structure (सिलेक्शन स्ट्रक्चर)
A selection structure selects a statement or block of statements for execution based on a condition. If the condition is true, the corresponding statement is executed. Otherwise, it may be skipped or another block may be executed.
सिलेक्शन स्ट्रक्चर किसी Condition के आधार पर स्टेटमेंट या स्टेटमेंट्स के समूह का चयन करता है। यदि Condition True होती है, तो संबंधित स्टेटमेंट Execute होता है। अन्यथा उसे Skip किया जा सकता है या किसी दूसरे Block को Execute किया जा सकता है।
Selection structures are implemented using:
ifstatementif-elsestatementelse-ifladderswitchstatementConditional operator (
?:)
Example: Even or Odd Number Program
Flow of Execution:
Start → Input Number → Check number % 2 == 0 → Display Even or Odd → Stop
3) Iterative Structure (इटरेटिव स्ट्रक्चर)
An iterative structure executes a statement or block of statements repeatedly, according to a condition. It is also known as a repetitive or loop structure.
इटरेटिव स्ट्रक्चर में किसी स्टेटमेंट या स्टेटमेंट्स के समूह को Condition के आधार पर बार-बार Execute किया जाता है। इसे Repetitive Structure या Loop Structure भी कहा जाता है।
Iterative structures are implemented using:
whileloopforloopdo-whileloop
Example: Counting from 1 to 100 or printing the multiplication table of a number.
Flow of Execution:
Start → Initialize Variable → Check Condition → Execute Loop Body → Update Variable → Check Condition Again → Stop when Condition is False
Control structures are important in programming because they determine how statements are executed. Sequential structures execute statements in order, selection structures make decisions, and iterative structures repeat statements.
प्रोग्रामिंग में Control Structures महत्वपूर्ण होते हैं क्योंकि ये स्टेटमेंट्स के Execution को नियंत्रित करते हैं। Sequential Structure स्टेटमेंट्स को क्रम में Execute करता है, Selection Structure निर्णय लेता है तथा Iterative Structure स्टेटमेंट्स को बार-बार Execute करता है।



Comments
Post a Comment