Xi Cs First Setb1 Ques
Xi Cs First Setb1 Ques
Xi Cs First Setb1 Ques
Max Marks : 70
General Instructions :
Q1a) Name the header files are required for the following :
i)
cout
ii)
setw( )
iii)
pow( )
iv)
exit( )
(2)
b)
Differentiate between a while loop and a do- while loop with example. (2)
c)
How many bytes are reserved for the following data types:
i)
float
ii)
int
(2)
(2)
g)
h)
Explain the difference between break and continue with the help of an
example.
(3)
i)
(2)
Q2 Find the syntax errors in the following code and write the corrected code
underlining the corrections made.
a) #include(iostream.h)
(3)
void main( )
int x; y;
cin>>x;
for (y= =0; y<10, y++)
if x= =y
cout<<y+x;
else
cout<<y;
b) #include<<iostream.h>>
void main( );
{
const int max=0;
int a,b;
cin>>a>>b;
if(a>b) max=a;
for(x; x<max; x++)cout>>x;
}
c) #include<iostream.h>
int main
{
int j=99,a;
float u=10.0;
cin(a);
while a<=j
{
a+=10
u=/a;
}
}
Q3.
(3)
(3)
Find the output of the following code (assuming all the necessary files are
included.)
a) #include<iostream.h>
void main( )
{
int i,j,k,x=0;
for(i=0;i<3;++i)
for(j=0;j<i;j++)
{ switch(i+j-1)
{
case -1:
case 0:
2
(4)
x+=1;
break;
case 1:
case 2:
case 3:
x+=3;
default:
x+=3;
}
cout<<x<< ;
}
cout<<"\n "<<x;
}
b)
(3)
c)
#include<iostream.h>
(4)
void main( )
{ for ( int a = 3 ; a< 10 ; a++ )
{ if ( a==4)
a+=5;
for ( int b = 4 ; b > 0 ; b--)
{ cout << b * a << @ ;
}
cout<< endl;
}
}
Q4.
(2)
(2)
c)
(2)
Q5 a) Write a program that reads the value of an integer n and then display the
following patterns till n number of lines. For e.g. If n=4 then the output
should be:
(4)
3
3
2
2
2
1
1
1
1
2
2
2
3
3
b) Write a program that reads two integer numbers n & m and then prints
every integer between 1 and n divisible by m. Also report whether the
number that is divisible by m is even or odd.
(4)
c)
Write a program that reads a given number and prints whether it is prime
or not. The program should continue as long as user wants.
(4)
d)
Write a program that reads a number, n and prints all armstrong numbers
from 1 to n.
(4)
e)
Write a program that reads a number n and find the sum of Fibonacci
series upto n terms.
(4)
f)
g)
(2)