Class 11 Computer Science
Class 11 Computer Science
Class 11 Computer Science
cin >>ch;
switch (ch)
{ case g: cout<<Good;
case b: cout<<Bad;
break;
case e: cout<< excellent ;
break;
default: cout<< wrong choice;
}
# 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; }
b) Convert the following code segment into switch case construct. 3
int ch;
cin>>ch;
If(ch = = 1)
{ cout<< Laptop;
}
else If(ch = = 2)
{
cout<<Desktop ;
} else if(ch= = 3) 114
{
cout<<Notebook;
} else
{
cout<<Invalid Choice;
}
}
}
c) Convert the following code segment into do-while loop. 3
#include<iostream.h>
void main()
{ int i;
for(i=1;i<=20;++i)
cout<<\n<<i;
}
d) Given the following code fragment
int ch=5;
cout << ++ch<< \n<<ch<<\n;
i) What output does the above code fragment produce?
ii) What is the effect of replacing ++ ch with ch+1? 2
5.a) Which header files are required for the following?
(i) frexp()( (ii) sqrt( ) (iii) rand( ) (iv) isupper() 2
b) Evaluate: 4
i) (12)10 = ( X)2
ii) (347)8= (X)10
iii) (896)16= (X)8
iv) (100)10= (X)2
6.a) Write a C++ program to check a year for leap year or not. 2
b) Write a C++ program to check a number for Armstrong or not. 4
c) Write a C++ program to calculate the factorial of any given number