NIOS Class 12 Computer Science Chapter 14 Control Statements Solutions English Medium As Per New Syllabus. to each chapter is provided in the list so that you can easily browse throughout different chapters NIOS Class 12 Computer Science Chapter 14 Control Statements Notes and select need one. NIOS Class 12 Computer Science Question Answers Download PDF. NIOS Study Material of Class 12 Computer Science Notes Paper 330.
NIOS Class 12 Computer Science Chapter 14 Control Statements
Also, you can read the NIOS book online in these sections Solutions by Expert Teachers as per National Institute of Open Schooling (NIOS) Book guidelines. These solutions are part of NIOS All Subject Solutions. Here we have given NIOS Class 12 Computer Science Textbook Solutions, NIOS Senior Secondary Course Computer Science Notes for All Chapter, You can practice these here.
Control Statements
Chapter: 14
| Module – 3: Programming in C++ |
INTEXT QUESTIONS 14.1
1. Identify the error(s), if any, in the following programs and write them in correct format.
(a) # include<iostream.h>
Void main ( )
int a, b;
cin<<b;<<a;
if (a>b) max = a
}
Ans:
#include <iostream.h>
void main()
{
int a, b, max;
cin >> b >> a;
if(a > b)
max = a;
cout << max;
}
(b) # include <iostream.h>
void main( ) {
int x, y;
cin >> x ;
for (y = 0 ; y < 10, y ++)
if x = = y cout << y + x ;
else
cout >> y;
}
Ans:
#include <iostream.h>
void main()
{
int x, y;
cin >> x;
for(y = 0; y < 10; y++)
{
if(x == y)
cout << y + x;
else
cout << y;
}
}
2. What will be the output of the following program segment?
(a) cin >> x;
if ( x = = 10 )
cout << “x is 10” ;
else
cout << “x is not 10” ;
if the input given is
(i) 11
Ans: x is not 10.
(ii) 10
Ans: x is 10.
(b) int year ;
cin >> year ;
if (year % 100 = = 0)
if (year % 400 = = 0)
{
cout << “Leap” ;
else
cout << “Not century year” ;
}
if the input is
(i) 2000
Ans: Leap.
(ii) 1971
Ans: No output.
(c) int year ;
cin >> year ;
if (year % 100 = = 0)
{
if (year % 400 = = 0)
cout << “Leap” ;
}
else
cout << “Not century year” ;
if the input given is
(i) 2000
Ans: Leap.
(ii) 1971
Ans: No century year.
3. What would be the value of c?
{
int c;
float a, b;
a = 245.05;
b = 40.02 ;
c = a + b;
}
(a) 285.09
(b) 2850
(c) 285
(d) 285.0
Ans: (c) 285
4. What would be the value of i and k?
{
int i, j, k ;
j = 5 ; i = 2 * j / 2 ;
k = 2 * (j/2) ;
}
(a) i = 4, k = 4
(b) i = 4, k = 5
(c) i = 5, k = 4
(d) i = 5, k = 5
Ans: (c) i = 5, k = 4
5. What is the output of the following program?
void main ( )
{
int x = 5, y = 6, z = 7;
if (x < y + z)
cout << “Hello \n” ;
else
{
cout << “How \n” ;
cout << “Are you \n”;
}
}
(a) Hello
(b) How
(c) Are you
(d) None of the above
Ans: (a) Hello.
6. Consider the program segment.
switch (choice)
{
case ‘W’ : cout << “WHITE” ;
case ‘R’ : cout << “RED” ;
case ‘B’ : cout << “BLUE” ;
default : cout << “error” ; break ;
}
What would be the output if choice = ‘R’?
(a) RED
(b) RED BLUE error
(c) RED error
(d) WHITE RED BLUE
Ans: (c) RED error .
INTEXT QUESTIONS 14.2
1. How many times will the following loop be executed?
(a) int s = 0, i = 0;
while ( i + + < 5)
s + = i;
Ans: 5 times.
(b) int s = 0 ; i = 0;
do
s + = i ;
while ( i < 5 ) ;
Ans: Endless loop.
2. What will be the output of the following program?
(a) # include <iostream.h>
void main ( )
{
long number = 7866372, result = 0 ;
do
{ result * = 10 ;
int digit = number % 10 ;
result + = digit ;
number / = 10 ;
}
while (number) ;
cout << “output =” << result << endl;
}
Ans: output= 2 7 3 6 6 8 7.
(b) void main ( )
{
int i = 0, a = 0, b = 0, c = 0, f = 0 ;
while ( i < = 5)
{
switch (i + +)
{
case 1 : case 2 : + + a ; break;
case 3 :
case 4 : + + b ; break;
case 5 : + + c ; break;
default : + + f ; break;
}
}
cout << a << “\n” ;
cout << b << “\n” ;
cout << c << “\n” ;
cout << f << “\n” ; }
3. What will be the value of counter after the following program is executed?
void main ( )
{
int counter ;
int digit = 0 ;
counter = 1 ;
while (digit < = 10)
{
+ + counter ;
+ + digit ;
}
cout <<counter ;
}
(a) 9
(b) 10
(c) 11
(d) 12
Ans: (d) 12.
Subject Ka Complete Video Solution Dekhein
Step-by-step easy concept explanation aur full questions Answer ke liye watch karein ya app download karein:

