Professional Documents
Culture Documents
Class Test 8
Class Test 8
(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
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;
}
}
}