You are on page 1of 1

Time:50 min Class Test 8 Max Marks 20

1(i) What will be the output of the following b. # include(iostream.h)


code fragment? 4 void main()
cout<<”Enter a value”; { int X, Y;
int a; cin>>X;
cin>>a; for(Y=0;y<10,Y++)
if(a = 5) if X==Y
cout<<”Five”; cout<<Y+X;
else else
cout<<”Not Five”; cout>>Y;
if the input given is (i)7 (ii) 5? }

(ii) What with be the output of the following 3. How many times the following loops
code fragment? 3 will execute? 4
int year;
cout<<”Enter year:”; a. int s = 0, i = 0;
cin>>year; while(i<5)
if(year % 100 == 0) s+=i++;
if(year % 400 == 0)
cout<<”LEAP”; b. int s = 0, i = 0;
else do
cout<<”Not Century Year”; s+=i;
if the input given is (i) 2000 (ii) 1900 (iii)1971? while(i<5);

(iii) What with be the output of the following 4. What is the output of the following
code fragment? 3 code fragment? 2

int year; a. for (int i=1; i<10; i++)


cout<<”Enter year:”; cout<<i;
cin>>year;
if(year % 100 == 0) b. for (int i=1; i<10; i++);
{ if(year % 400 == 0) cout<<I;
cout<<”LEAP”;
}
else
cout<<”Not Century Year”;

if the input given is (i) 2000 (ii) 1900(iii)1971?

2. Find the syntax error(s), if any, in the


following program: 4

a. include <iostream.h>
void main()
{ int R; W = 90;
while W>60
{
R=W – 50;
switch(W)
{20: cout<<”Lower range”<<endl;
30: cout<<”Middle range”<<endl;
20: cout<<”Higher range”<<endl;
}
}
}

You might also like