UP Board Solutions Class 12 Computer Chapter 10 कण्ट्रोल स्टेटमेण्ट्स

Get the most accurate UP Board Solutions for Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स here. Updated for the 2026 27 academic session, these solutions are based on the latest UP Board textbooks for Class 12 Computer Science. Our expert-created answers for Class 12 Computer Science are available for free download in PDF format.

Detailed Chapter 10 कन्ट्रोल स्टेटमैंट्स UP Board Solutions for Class 12 Computer Science

For Class 12 students, solving UP Board textbook questions is the most effective way to build a strong conceptual foundation. Our Class 12 Computer Science solutions follow a detailed, step-by-step approach to ensure you understand the logic behind every answer. Practicing these Chapter 10 कन्ट्रोल स्टेटमैंट्स solutions will improve your exam performance.

Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स UP Board Solutions PDF

बहुविकल्पीय प्रश्न (1 अंक)

 

Question 1. if, if-else तथा switch स्टेटमेण्मेट्स हैं:
(a) ब्रांचिंग
(b) जम्पिंग
(c) लूपिंग
(d) कण्डीशन
Answer: (a) ब्रांचिंग
In simple words: These statements are called branching statements because they allow the program to choose different paths or branches of code to run based on a condition.

🎯 Exam Tip: Remember that branching statements control the flow of execution by making decisions, unlike loops which repeat code.

 

Question 2. निम्न में से कौन-सा लूप स्टेटमेण्मेट नहीं है? [2013]
(a) if
(b) do-while
(c) while
(d) for
Answer: (a) if
In simple words: An 'if' statement is a branching statement used for decision-making, whereas 'while', 'do-while', and 'for' are loops used for repeating code.

🎯 Exam Tip: Clearly distinguish between decision-making (branching) statements and iteration (looping) statements to avoid confusion in multiple-choice questions.

 

Question 3. default की-वर्ड किसमें प्रयोग किया जाता है?
(a) goto
(b) if
(c) if-else
(d) switch
Answer: (d) switch
In simple words: The 'default' keyword is used inside a switch block to run a backup set of instructions if none of the other cases match.

🎯 Exam Tip: Always remember that 'default' in a switch statement acts like the final 'else' in an if-else-if ladder.

 

Question 4. break स्टेटमेण्मेट का प्रयोग निम्न में से किससे बाहर जाने में किया जा सकता है?
(a) for लूप
(b) while लूप
(c) Switch स्टेटमेण्मेट
(d) All of the options
Answer: (d) All of the options
In simple words: The 'break' statement is a powerful tool that lets you instantly exit out of any loop or switch block whenever you need to stop.

🎯 Exam Tip: Keep in mind that 'break' immediately terminates the innermost loop or switch statement in which it appears.

 

Question 5. निम्न में से कौन-सा प्रोसेस संख्याओं को निश्चित अंक तक चलाने के लिए उच्चतम है?
(a) for
(b) while
(c) do-while
(d) All of the options
Answer: (a) for
In simple words: The 'for' loop is the best choice when you already know the exact number of times you want to repeat a block of code.

🎯 Exam Tip: Use the 'for' loop when the number of iterations is predetermined, and 'while' or 'do-while' when the loop depends on a dynamic condition.

 

Question 6. निम्न में से i++; स्टेटमेण्मेट किसके समान है?
(a) i = i + i;
(b) i = i + 1;
(c) i = i - 1;
(d) i--;
Answer: (b) i = i + 1;
In simple words: The expression 'i++' is a shorthand increment operator that simply adds 1 to the current value of the variable 'i'.

🎯 Exam Tip: Increment (++) and decrement (--) operators are frequently asked; make sure you understand how they modify variable values by exactly 1.

 

Question 7. Unconditional branching statement का उदाहरण है [2007]
(a) if else
(b) go to
(c) switch
(d) None of the options
Answer: (b) go to
In simple words: A 'goto' statement is unconditional because it jumps directly to another part of the program without checking any true or false conditions.

🎯 Exam Tip: Identify 'goto' as the primary unconditional branching statement, as it bypasses standard conditional checks entirely.

अतिलघु उत्तरीय प्रश्न (1 अंक)

 

Question 1. कोई नम्बर 2 से विभाजित है अथवा नहीं इसके लिए स्टेटमेंट लिखिए।
Answer: if (n%2 == 0)
In simple words: यह स्टेटमेंट चेक करता है कि क्या संख्या को 2 से भाग देने पर शेषफल 0 बचता है, जिससे पता चलता है कि संख्या सम (even) है।

🎯 Exam Tip: C++ में मॉड्युलो ऑपरेटर (%) का उपयोग शेषफल ज्ञात करने के लिए किया जाता है, इसे हमेशा याद रखें।

 

Question 2. switch स्टेटमेंट का प्रयोग क्यों किया जाता है?
Answer: switch स्टेटमेंट का प्रयोग प्रोग्राम में दिए गए अनेक मार्गों में से किसी एक का चयन करने में किया जाता है। यह कोड को अधिक व्यवस्थित और पढ़ने में आसान बनाता है।
In simple words: जब हमारे पास बहुत सारे विकल्प होते हैं और उनमें से किसी एक को चुनना होता है, तब हम switch स्टेटमेंट का उपयोग करते हैं।

🎯 Exam Tip: बहु-विकल्पीय परिस्थितियों में nested if-else के स्थान पर switch का उपयोग करना बेहतर माना जाता है।

 

Question 3. लूपिंग किसे कहते हैं?
Answer: किसी प्रोग्राम में निर्देश या निर्देशों के समूहों को एक से अधिक बार एक्जीक्यूट करने को लूपिंग कहते हैं। यह प्रोग्रामिंग में दोहराव वाले कार्यों को आसान बनाता है।
In simple words: जब हम किसी कोड को बार-बार चलाना चाहते हैं, तो हम लूप का उपयोग करते हैं ताकि हमें वही कोड बार-बार न लिखना पड़े।

🎯 Exam Tip: लूपिंग की परिभाषा लिखते समय 'पुनरावृत्ति' (iteration) या 'एक्जीक्यूशन' जैसे मुख्य शब्दों का प्रयोग अवश्य करें।

 

Question 4. जब हमें एक निश्चित संख्या में दोहराव (Repetition) करना हो, तो किस लूप का प्रयोग किया जाता है?
Answer: for लूप द्वारा निश्चित संख्या में दोहराव लाया जाता है। यह लूप तब सबसे उपयोगी होता है जब हमें पहले से पता हो कि लूप कितनी बार चलेगा।
In simple words: जब हमें पता हो कि कोई काम ठीक 10 या 50 बार करना है, तो हम for लूप का इस्तेमाल करते हैं।

🎯 Exam Tip: निश्चित संख्या में दोहराव के लिए हमेशा 'for loop' को प्राथमिकता दी जाती है क्योंकि इसमें इनिशियलाइजेशन, कंडीशन और इंक्रीमेंट एक ही लाइन में होते हैं।

 

Question 5. while लूप और do-while लूप में क्या अन्तर है? [2007]
Answer: while लूप में पहले कण्डीशन चैक की जाती है। इसके बाद लूप की बॉडी एक्जीक्यूट होती है, जबकि do-while में पहले लूप की बॉडी एक्जीक्यूट होती है फिर कण्डीशन चैक की जाती है। इस कारण do-while लूप कम से कम एक बार अवश्य चलता है चाहे कंडीशन गलत ही क्यों न हो।
In simple words: while लूप पहले शर्त देखता है फिर काम करता है, जबकि do-while पहले एक बार काम कर लेता है और फिर शर्त चेक करता है।

🎯 Exam Tip: परीक्षा में अंतर स्पष्ट करने के लिए दोनों लूपों का एक-एक छोटा सिंटैक्स उदाहरण भी लिख सकते हैं जिससे पूरे अंक मिलना सुनिश्चित होता है।

 

Question 6. किस स्टेटमेंट का प्रयोग किसी लूप के शेष स्टेटमेंटों को छोड़कर आगे बढ़ जाने के लिए किया जाता है?
Answer: continue स्टेटमेंट का प्रयोग किसी लूप के शेष स्टेटमेंटों को छोड़कर आगे बढ़ जाने के लिए किया जाता है। यह वर्तमान इटरेशन को वहीं समाप्त कर अगले इटरेशन पर भेज देता है।
In simple words: continue स्टेटमेंट लूप के अंदर के बाकी बचे काम को छोड़कर सीधे अगली बारी (next round) पर पहुँचा देता है।

🎯 Exam Tip: break और continue के बीच का अंतर अक्सर पूछा जाता है; याद रखें कि break लूप को पूरी तरह रोक देता है जबकि continue केवल वर्तमान चक्र को छोड़ता है।

 

लघु उत्तरीय प्रश्न I (2 अंक)

 

Question 1. ब्रांचिंग पर संक्षिप्त टिप्पणी कीजिए। [2003]
Answer: जब C++ प्रोग्राम में किसी स्टेटमेंट पर ऐसी स्थिति आती है कि वहाँ से आगे बढ़ने के लिए एक से अधिक मार्ग होते हैं, तो ऐसी स्थिति ब्रांचिंग कहलाती है। ब्रांचिंग स्थिति को हल करने के लिए ब्रांचिंग कन्ट्रोल स्टेटमेंट का प्रयोग किया जाता है, जो निम्न हैं:
1. if स्टेटमेंट
2. if-else स्टेटमेंट
3. switch स्टेटमेंट
ये स्टेटमेंट प्रोग्राम के सामान्य प्रवाह को बदलने में मदद करते हैं।
In simple words: प्रोग्राम में जब किसी शर्त के आधार पर अलग-अलग रास्तों पर जाना होता है, तो उसे ब्रांचिंग कहते हैं। जैसे - यदि बारिश होगी तो छाता लेंगे, नहीं तो नहीं।

🎯 Exam Tip: ब्रांचिंग के प्रकारों को बिंदुवार (bullet points) लिखने से उत्तर स्पष्ट दिखता है और पूरे अंक मिलते हैं।

 

Question 2. लूप्स की नेस्टिंग उपयुक्त उदाहरण देकर व्याख्या कीजिए। [2018]
Answer: जब हम एक लूप के अन्दर दूसरी लूप लगाते हैं, तो इस प्रकार की लूप नेस्टिड लूप या लूप्स की नेस्टिंग कहलाती है। इसमें बाहरी लूप के प्रत्येक चक्र के लिए आंतरिक लूप पूरी तरह से चलता है।

उदाहरण:

#include<iostream.h>
void main( )
{
    int n, i;
    for (n = 1; n <= 10; n = n + 1)
    {
        cout << "Table is : " << endl;
        for (i = 1; i <= 10; i++)
        {
            cout << n * i << endl;
        }
        cout << endl;
    }
}

In simple words: जब एक लूप के पेट (अंदर) दूसरा लूप रख दिया जाता है, तो उसे नेस्टेड लूप कहते हैं। जैसे घड़ी में मिनट की सुई के एक चक्कर के अंदर सेकंड की सुई 60 चक्कर लगाती है।

🎯 Exam Tip: नेस्टेड लूप का उदाहरण देते समय कोष्ठक (curly braces `{}`) और इंडेंटेशन का विशेष ध्यान रखें ताकि कोड समझने में आसानी हो।

 

Question 3. break एवं continue स्टेटमेंट की उपयोगिता को उदाहरण सहित समझाइए। [2006] अथवा break व continue में अन्तर स्पष्ट कीजिए। [2007] अथवा उपयुक्त उदाहरण देकर break व continue स्टेटमेंट्स में भेद करें। [2018]
Answer: break व continue में अन्तर निम्न हैं:

breakलूप से बाहर निकलने के लिए break स्टेटमेंट का प्रयोग होता है।
continueलूप के शेष स्टेटमेंटों को छोड़कर आगे बढ़ जाने के लिए continue स्टेटमेंट का प्रयोग होता है।
उदाहरण (break):
for(int i = 1; i <= 5; i++)
{
    if(i % 2 == 0)
        break;
    cout << i;
}

उदाहरण (continue):
for(int i = 1; i <= 5; i++)
{
    if(i % 2 == 0)
        continue;
    cout << i;
}

ये दोनों कंट्रोल स्टेटमेंट्स लूप के प्रवाह को अपनी आवश्यकतानुसार मोड़ने और प्रोग्राम को अधिक कुशल बनाने में बहुत महत्वपूर्ण भूमिका निभाते हैं।
In simple words: The break statement completely stops the loop and exits from it immediately, whereas the continue statement only skips the current iteration and jumps directly to the next turn of the loop.

🎯 Exam Tip: Always write short, clean code examples alongside the theoretical differences to secure full marks in comparison questions.

 

Question 4. किसी संख्या का फैक्टोरियल निकालने हेतु C++ में प्रोग्राम लिखिए। [2011]
Answer:
#include<iostream.h>
void main()
{
    int num, i, f = 1;
    cout << "Enter the number:";
    cin >> num;
    for(i = num; i > 0; i--)
    {
        f = f * i;
    }
    cout << "Factorial of the number:" << f;
}

आउटपुट: Enter the number: 5 Factorial of the number : 120

यह प्रोग्राम यूजर से कोई भी धनात्मक पूर्णांक इनपुट लेकर लूप की मदद से उसका फैक्टोरियल मान बहुत ही कम समय में शुद्धता से ज्ञात कर लेता है।
In simple words: This program calculates the factorial of a number (like 5! = 5 × 4 × 3 × 2 × 1 = 120) by multiplying the numbers in decreasing order using a simple loop.

🎯 Exam Tip: Do not forget to initialize the factorial variable 'f' to 1, because initializing it to 0 will make the entire multiplication result zero.

 

Question 5. C++ में प्रारम्भिक 10 संख्याओं का औसत मान ज्ञात करने के लिए प्रोग्राम लिखिए।
Answer:
#include<iostream.h>
void main()
{
    int sum = 0;
    float average;
    for(int i = 1; i <= 10; i++)
    {
        sum = sum + i;
    }
    average = sum / 10.0;
    cout << "Average of first 10 numbers is: " << average;
}

यह प्रोग्राम पहले 10 प्राकृतिक संख्याओं का योग निकालकर उसे कुल संख्या यानी 10 से विभाजित करके सटीक औसत मान प्रदर्शित करता है।
In simple words: This program adds up all the numbers from 1 to 10 using a loop and then divides the total sum by 10 to find their average value.

🎯 Exam Tip: Always use a float data type for the average variable and divide by 10.0 instead of 10 to get the precise decimal value in the output.

Question 6. एक C++ प्रोग्राम लिखिए, जो A से H तक सीरीज प्रिण्ट करे, परन्तु उसमें C तथा F उपस्थित न हो।
Answer:
#include<iostream.h>
void main()
{
    for (char i = 'A'; i <= 'H'; ++i)
    {
        if (i == 'C' || i == 'F')
        {
            continue;
        }
        cout << i << "\t";
    }
}

आउटपुट: A B D E G H
This program successfully demonstrates the use of the continue statement to skip specific iterations in a loop.
In simple words: This program prints letters from A to H. When it reaches 'C' or 'F', the 'continue' statement skips them so they do not get printed on the screen.

🎯 Exam Tip: When writing programs that skip certain values, always use the 'continue' statement inside an 'if' condition to score full marks.

 

लघु उत्तरीय प्रश्न II (3 अंक)

 

Question 1. उदाहरण सहित do-while व for लूप में भेद करें। [2016, 14]
Answer: do-while व for लूप में मुख्य अंतर निम्नलिखित हैं:

do-while लूप (do-while Loop)for लूप (for Loop)
1. इस लूप में लूप काउंटर इनिशियलाइजेशन, कंडीशन की जाँच तथा काउंटर में वृद्धि या कमी को एक साथ नहीं लिखा जा सकता है।1. इस लूप में लूप काउंटर इनिशियलाइजेशन, कंडीशन की जाँच तथा काउंटर में वृद्धि या कमी को एक ही लाइन में लिखा जा सकता है।
2. यह एक Exit-controlled लूप है, जिसमें कंडीशन बाद में जाँची जाती है। इसलिए यह कम से कम एक बार जरूर चलता है।2. यह एक Entry-controlled लूप है, जिसमें कंडीशन पहले जाँची जाती है। यदि कंडीशन शुरू में ही गलत हो, तो लूप एक बार भी नहीं चलता।
उदाहरण:
int i = 1;
do {
    cout << i << " ";
    i++;
} while(i <= 5);
उदाहरण:
for(int i = 1; i <= 5; i++) {
    cout << i << " ";
}
Choosing the correct loop structure is essential for writing clean and optimized code in C++.
In simple words: A 'for' loop checks the condition at the start, so it won't run if the condition is false. A 'do-while' loop checks the condition at the end, meaning it will always run at least once.

🎯 Exam Tip: Always draw a comparison table and write a short code example for both loops to secure maximum marks in comparison questions.

उदाहरण: do-while की सहायता से 1 से 20 तक की संख्याओं का योग निकालना
#include<iostream.h>
void main( )
{
int i= 1, sum = 0;
do
{
sum = sum + i;
i++;
} while(i<=20);
cout<<"The sum is:"<< sum;
}

आउटपुट: The sum is : 210

 

उदाहरण: for लूप की सहायता से 1 से 20 तक की संख्याओं का योग निकालना
#include<iostream.h>
void main( )
{
int i, sum = 0;
for(i = 1 ; i <= 20 ; i++)
{
sum = sum + i;
}
cout<<"The sum is :" << sum;
}

आउटपुट: The sum is : 210

 

Question 2. for लूप का प्रयोग करके प्रथम 1000 पूर्णांकों का योगफल ज्ञात - करने हेतु एक प्रोग्राम लिखिए। [2013]
Answer:
#include<iostream.h>
void main( )
{
int i;
long sum = 0;
for(i = 0; i < 1000; i++)
{
sum = sum + i;
}
cout<<"The sum is:"<<sum;
}

आउटपुट: The sum is : 500500
In simple words: This program uses a 'for' loop to add numbers from 0 to 999 one by one, storing the total in a variable called 'sum' and then printing it.

🎯 Exam Tip: Always use the 'long' data type for variables storing cumulative sums of large numbers to prevent integer overflow errors.

 

Question 3. do-while लूप का प्रयोग करके प्रथम एक सौ विषम संख्याओं का योगफल छापने हेतु C++ भाषा में एक प्रोग्राम लिखिए। [2013]
Answer:
#include<iostream.h>
void main( )
{
int i = 1, sum = 0, count = 0;
do
{
sum = sum + i;
i = i + 2;
count++;
} while(count < 100);
cout<<"The sum is:"<<sum;
}
In simple words: This program uses a 'do-while' loop to add the first 100 odd numbers (like 1, 3, 5...) together and prints their total sum.

🎯 Exam Tip: Remember that a do-while loop executes at least once before checking the condition, so initialize your loop control variables carefully.

 

Question 4. goto, break व continue स्टेटमेंट्स को समझाइए। [2016]
Answer:
1. goto स्टेटमेंट: इस स्टेटमेंट का प्रयोग प्रोग्राम के एक्जीक्यूशन का सामान्य क्रम बदलने के लिए किया जाता है, जिससे प्रोग्राम का नियन्त्रण प्रोग्राम में किसी अन्य स्थान पर बिना शर्त अन्तरित हो जाता है।
प्रारूप: goto label_name;

2. break स्टेटमेंट: इस स्टेटमेंट का प्रयोग किसी भी प्रकार के लूप से बाहर निकलने के लिए किया जाता है। यह केवल सबसे भीतरी लूप के लिए लागू होगा, जिसमें इसका प्रयोग किया गया हो।
प्रारूप: break;

3. continue स्टेटमेंट: इस स्टेटमेंट का प्रयोग किसी लूप के शेष स्टेटमेंट्स को छोड़कर आगे बढ़ जाने के लिए किया जाता है। इस स्टेटमेंट के प्रयोग से लूप समाप्त नहीं होता, बल्कि उस पास (Pass) में लूप के आगे के स्टेटमेंट को छोड़ दिया जाता है। अगले पासों में लूप सामान्य रूप में चलता रहता है। इन कंट्रोल स्टेटमेंट्स का सही उपयोग प्रोग्राम के प्रवाह को अधिक लचीला और कुशल बनाता है।
प्रारूप: continue;
In simple words: 'goto' jumps directly to another part of the code, 'break' completely stops and exits a loop, and 'continue' skips the rest of the current loop cycle and moves directly to the next iteration.

🎯 Exam Tip: Always write the syntax (प्रारूप) for each statement along with its explanation to secure full marks.

 

Question 5. C++ में एक प्रोग्राम लिखिए, जो किसी दो अंकीय पूर्णांक का पहाड़ा छापे। [2016]
Answer:
नीचे दिया गया C++ प्रोग्राम उपयोगकर्ता द्वारा दर्ज किए गए किसी भी दो अंकीय पूर्णांक का पहाड़ा प्रदर्शित करता है:

#include<iostream.h>
void main( )
{
    int n, i, table;
    cout<<"Enter the number:";
    cin>>n;
    cout<<"Table\n";
    for(i = 1; i <= 10; i++)
    {
        table = n * i;
        cout<< table << endl;
    }
}

आउटपुट:
Enter the number: 12
Table
12
24
36
48
60
72
84
96
108
120

यह प्रोग्राम उपयोगकर्ता से इनपुट लेकर लूप की मदद से आसानी से किसी भी संख्या का पहाड़ा प्रदर्शित कर सकता है।
In simple words: This program asks the user to enter a number, then uses a 'for' loop to multiply that number by 1 to 10, printing each result on a new line to show the complete multiplication table.

🎯 Exam Tip: Remember to include the header file #include<iostream.h> and write the expected output clearly to show that your program works correctly.

 

Question 6. C++ में तीन संख्याएँ इनपुट कीजिए तथा फिर उनमें से सबसे बड़ी को बताइए।
Answer:
#include<iostream.h>
void main()
{
    int a, b, c;
    cout<<"Enter the value of a, b and c\n";
    cin>>a>>b>>c;
    if((a > b) && (a > c))
    {
        cout<<"a is the largest number";
    }
    else if((b > a) && (b > c))
    {
        cout<<"b is the largest number";
    }
    else
    {
        cout<<"c is the largest number";
    }
}

Output:
Enter the value of a, b and c 12 34 54
c is the largest number
In simple words: This program takes three numbers from the user and uses "if-else" conditions to compare them and find which one is the biggest.

🎯 Exam Tip: Remember to use the logical AND operator (&&) to check if a number is greater than both of the other two numbers simultaneously.

 

Question 7. C++ में एक पाँच अंकीय संख्या के समस्त अंकों का योग प्रदर्शित करने हेतु एक प्रोग्राम लिखिए। [2008]
Answer:
#include<iostream.h>
void main()
{
    long n, sum = 0, p;
    cout<<"Enter any number:";
    cin>>n;
    while(n != 0)
    {
        p = n % 10;
        sum += p;
        n = n / 10;
    }
    cout<<endl<<"Sum of digits is:"<<sum;
}

Output:
Enter any number: 36768
Sum of digits is : 30
In simple words: This program finds the sum of all digits of a number by repeatedly taking the last digit using the remainder operator (%) and adding it to a running total.

🎯 Exam Tip: Use the modulo operator (%) to extract the last digit of a number and division (/) to remove the last digit in a loop.

 

Question 8. किसी दी हुई संख्या को उलट कर लिखने के लिए एक C++ प्रोग्राम लिखिए। [2009]
Answer:
#include<iostream.h>
void main()
{
    int n, rev = 0, rem;
    cout<<"Enter an integer:";
    cin>>n;
    while(n != 0)
    {
        rem = n % 10;
        rev = rev * 10 + rem;
        n = n / 10;
    }
    cout<<"Reversed number is: "<<rev;
}

Output:
Enter an integer: 12345
Reversed number is: 54321
In simple words: This program reverses a number by extracting its digits from right to left and building a new number in reverse order.

🎯 Exam Tip: To reverse a number, multiply the previous reversed value by 10 before adding the newly extracted digit.

Question 9. do-while लूप की सहायता से 8 व 11 का पहाड़ा लिखने हेतु C++ भाषा में एक प्रोग्राम लिखिए। (2003)
Answer:
#include<iostream.h>
void main( )
{
  int n,m;
  cout<<"Enter n:";
  cin>>n;
  cout<<"Enter m:";
  cin>>m;
  int i = 1;
  do
  {
    cout<<n*i<<"\t"<<m*i<<endl;
    i++;
  } while (i <= 10);
}

Output:
Enter n: 8 Enter m: 11
8    11
16    22
24    33
32    44
40    55
48    66
56    77
64    88
72    99
80    110
This program demonstrates how to handle multiple inputs simultaneously inside a loop.
In simple words: This program takes two numbers as input and uses a do-while loop to print their multiplication tables side-by-side up to 10.

🎯 Exam Tip: Remember that a do-while loop executes at least once even if the condition is false. Always write the loop condition with a semicolon at the end.

 

Question 10. -100 व 100 के बीच पड़ने वाली सभी विषम संख्याओं का योग निकालने के लिए C++ में एक प्रोग्राम लिखिए। [2018]
Answer:
#include<iostream.h>
void main( )
{
  int i, sum=0;
  for (i = -100; i <= 100; i++)
  {
    if (i % 2 != 0)
    {
      sum = sum + i;
    }
  }
  cout<<"The sum is: " <<sum;
}

Output:
The sum is : 0
This demonstrates the mathematical property of symmetry in positive and negative integers.
In simple words: This program loops through all numbers from -100 to 100, checks if each number is odd, and adds them together. Since positive and negative odd numbers cancel each other out, the final sum is 0.

🎯 Exam Tip: When writing loops for summing values, always initialize your sum variable to 0 to avoid garbage values affecting your final result.

 

Question 11. for लूप का प्रयोग करते हुए 5 का पहाड़ा छापने के लिए C++ में एक प्रोग्राम लिखिए। [2018]
Answer:
#include<iostream.h>
void main()
{
  for (int i = 1; i <= 10; i++)
  {
    cout<<"5 * "<<i<<" = "<<5*i<<endl;
  }
}

Output:
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
This is a fundamental exercise to understand loop control variables.
In simple words: This program uses a simple for loop that runs 10 times, multiplying 5 by the loop counter each time to print the table of 5.

🎯 Exam Tip: For simple multiplication tables, using a standard for loop from 1 to 10 is the most efficient and readable approach.

दीर्घ उत्तरीय प्रश्न (5 अंक)

 

Question 1. ब्रांचिंग का संक्षिप्त विवरण दीजिए। दी गई संख्या सम है या विषम, जानने के लिए C++ में प्रोग्राम लिखिए। [2012, 03]
Answer: जब C++ प्रोग्राम में किसी स्टेटमेंट पर ऐसी स्थिति आती है कि वहाँ से आगे बढ़ने के लिए एक से अधिक मार्ग होते हैं तो ऐसी स्थिति ब्रांचिंग (Branching) कहलाती है। ब्रांचिंग स्थिति को हल करने के लिए ब्रांचिंग कण्ट्रोल स्टेटमेंट का प्रयोग किया जाता है, जो निम्न हैं:
1. if स्टेटमेंट
2. if-else स्टेटमेंट
3. switch स्टेटमेंट

दी गई संख्या सम है या विषम, जानने के लिए प्रोग्राम:
#include<iostream.h>
void main( )
{
int num;
cout<<"Enter the number:";
cin>>num;
if (num % 2 == 0)
cout<<"The number is Even";
else
cout<<"The number is Odd";
}

आउटपुट:
Enter the number : 25
The number is Odd
In simple words: Branching is used in C++ when the program has to make a decision and choose one path out of multiple options based on a condition, such as checking if a number is even or odd.

🎯 Exam Tip: Always write the complete syntax of control statements and provide a clean, indented program with its expected output to score full marks.

 

Question 2. C++ में, for तथा while loops का वर्णन कीजिए। C++ में, स्क्रीन पर निम्न चित्र को दर्शाने हेतु प्रोग्राम लिखिए। [2014, 12] * * * * * * * * * * * * * * * *
Answer: for लूप: इस लूप का प्रयोग प्रोग्राम में ऐसे स्थानों पर किया जाता है जहाँ हमें किसी स्टेटमेंट या स्टेटमेंट के समूह का एक्जीक्यूशन एक निश्चित बार कराना हो। यह एक एंट्री-कंट्रोल लूप है।
while लूप: इस लूप का प्रयोग प्रोग्राम में ऐसे स्थानों पर किया जाता है जहाँ हमें यह पता नहीं होता कि लूप का एक्जीक्यूशन कितनी बार किया जाएगा। इसमें प्रत्येक बार लूप का एक्जीक्यूशन करने से पहले एक शर्त की जाँच की जाती है, जिसके सत्य होने पर ही लूप के स्टेटमेंटों को एक्जीक्यूट किया जाता है अन्यथा कण्ट्रोल लूप से बाहर आ जाता है।

स्क्रीन पर '*' चित्र दर्शाने हेतु प्रोग्राम:
#include<iostream.h>
void main( )
{
for(int i = 1; i <= 16; i++)
{
cout<<"* ";
}
}
In simple words: A 'for' loop is used when we know exactly how many times to repeat a task, while a 'while' loop repeats a task as long as a certain condition remains true.

🎯 Exam Tip: Clearly differentiate between entry-controlled (for, while) and exit-controlled (do-while) loops, and write clean code with proper loop initialization, condition, and increment/decrement steps.

 

प्रश्न 3. 1 से 10 तक का पहाड़ा लिखने के लिए C++ में while लूप का प्रयोग करते हुए एक प्रोग्राम लिखिए। [2014]
उत्तर:
#include<iostream.h>
void main( )
{
    int i, j;
    for(i = 1; i <= 10 ; i++)
    {
        j = 1;
        while(j <= 10)
        {
            cout<<i*j<<"\t";
            j++;
        }
        cout<< endl;
    }
}

आउटपुट (Output):

12345678910
2468101214161820
36912151821242730
481216202428323640
5101520253035404550
6121824303642485460
7142128354249566370
8162432404856647280
9182736455463728190
102030405060708090100

In simple words: इस प्रोग्राम में nested loops का उपयोग किया गया है। बाहरी loop (for) 1 से 10 तक की पंक्तियों को नियंत्रित करता है, और आंतरिक loop (while) प्रत्येक संख्या का पहाड़ा प्रिंट करता है।

🎯 Exam Tip: परीक्षा में nested loops वाले प्रोग्राम लिखते समय curly braces `{}` का सही मिलान सुनिश्चित करें ताकि syntax error न हो।

 

प्रश्न 4. C++ में किन्हीं दस संख्याओं का योग एवं औसत प्रदर्शित करने हेतु प्रोग्राम लिखिए। (अपनी इच्छानुसार अंक ले) (2008)
उत्तर:
#include<iostream.h>
void main( )
{
    int i, sum = 0, avg, num;
    cout<<"Enter 10 numbers: "<<endl;
    for(i = 1; i <= 10; i++)
    {
        cin>>num;
        sum = sum + num;
    }
    avg = sum / 10;
    cout<<"Sum = "<<sum<<endl;
    cout<<"Average = "<<avg<<endl;
}
In simple words: यह प्रोग्राम यूजर से 10 संख्याएं इनपुट लेता है, उन्हें जोड़कर कुल योग (sum) निकालता है, और फिर कुल योग को 10 से भाग देकर औसत (average) ज्ञात करता है।

🎯 Exam Tip: औसत (average) निकालते समय ध्यान रखें कि यदि संख्याएं दशमलव में हो सकती हैं, तो float डेटा टाइप का उपयोग करना अधिक उपयुक्त होता है।

 

Question 5. निम्न श्रेणी का योग ज्ञात करने के लिए C++ में एक प्रोग्राम लिखिए। \( 1 + \frac { 1 }{ 2 } + \frac { 1 }{ 3 } + \dots + \frac { 1 }{ n } \)
Answer:
#include<iostream.h>
void main( )
{
  int n;
  double i, sum = 0;
  cout<<"1 + \( \frac { 1 }{ 2 } \) + \( \frac { 1 }{ 3 } \) + ... + \( \frac { 1 }{ n } \)"<<endl;
  cout<<"Enter the value of n:"<<endl;
  cin >>n;
  for(i = 1; i <=n; i++)
  {
    sum = sum + (1/i);
  }
  cout<< "The sum of series is:"<< sum;
}

This program uses a loop to iterate from 1 to n, adding the reciprocal of each number to the sum.

आउटपुट:
1 + \( \frac { 1 }{ 2 } \) + \( \frac { 1 }{ 3 } \) + \( \frac { 1 }{ 4 } \) + ... + \( \frac { 1 }{ n } \)
Enter the value of n: 5
The sum of series is : 2.283333
In simple words: This program calculates the sum of a series of fractions like 1 + 1/2 + 1/3 up to 1/n. It asks the user for a number 'n', then adds all these fractions together using a loop and prints the final total.

🎯 Exam Tip: Always declare the loop variable and sum as double or float when dealing with division to avoid integer division truncation, which would result in incorrect fractional sums.

UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स

Students can now access the UP Board Solutions for Chapter 10 कन्ट्रोल स्टेटमैंट्स prepared by teachers on our website. These solutions cover all questions in exercise in your Class 12 Computer Science textbook. Each answer is updated based on the current academic session as per the latest UP Board syllabus.

Detailed Explanations for Chapter 10 कन्ट्रोल स्टेटमैंट्स

Our expert teachers have provided step-by-step explanations for all the difficult questions in the Class 12 Computer Science chapter. Along with the final answers, we have also explained the concept behind it to help you build stronger understanding of each topic. This will be really helpful for Class 12 students who want to understand both theoretical and practical questions. By studying these UP Board Questions and Answers your basic concepts will improve a lot.

Benefits of using Computer Science Class 12 Solved Papers

Using our Computer Science solutions regularly students will be able to improve their logical thinking and problem-solving speed. These Class 12 solutions are a guide for self-study and homework assistance. Along with the chapter-wise solutions, you should also refer to our Revision Notes and Sample Papers for Chapter 10 कन्ट्रोल स्टेटमैंट्स to get a complete preparation experience.

FAQs

Where can I find the latest UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स for the 2026 27 session?

The complete and updated UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स is available for free on StudiesToday.com. These solutions for Class 12 Computer Science are as per latest UP Board curriculum.

Are the Computer Science UP Board solutions for Class 12 updated for the new 50% competency-based exam pattern?

Yes, our experts have revised the UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.

How do these Class 12 UP Board solutions help in scoring 90% plus marks?

Toppers recommend using UP Board language because UP Board marking schemes are strictly based on textbook definitions. Our UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स will help students to get full marks in the theory paper.

Do you offer UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 12 Computer Science. You can access UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स in both English and Hindi medium.

Is it possible to download the Computer Science UP Board solutions for Class 12 as a PDF?

Yes, you can download the entire UP Board Solutions Class 12 Computer Science Chapter 10 कन्ट्रोल स्टेटमैंट्स in printable PDF format for offline study on any device.