Você está na página 1de 3

Assignment No.

6: Class XI
Q1. Give the Output for the following:
a. int a=300, b=0, c=0;
if(a>=400)
{
b=300;
cout<<a<<b<<c;
}
b. int a=3;
a=a+1;
if(a>5)
cout<<a;
else
cout<<(a+5);
c. int i=0, x=0;
while(i<10)
{
If((i%2)==0)
{
x=x+i;
cout<<x;
I++;
}
}
d. int i=0;
for(i=1;i<=20;i++)
{
cout<<I;
i=i+1;
}
e. void main()
{
int i=0, x=0;
for(i=1;i<10;i++)
{
X++;
cout<<x;
}
cout<<\n<<x;
}

f. void main()
{
int i;
for(i=0;i<10;i++)
{
If(i==5)
break;
cout<<I;
}
}
g. for(int i=1;i<10;i++)
if( i==4)
cout<<i=<<i;
h. for( int i=10;i>6;i=i-2)
{
cout<<i<<endl;
}
i. int i=100, j=9;
cout<<i/j<<endl;
cout<<i%j<<endl;
j. void fun1(int p, int&q)
{
int t=p*q;
p+=t;
if( q= =100)
cout<<\n<<p<<\t<<q<<\t<<t;
else
cout<<\n<<p<<\t<<q;
}
void main()
{
clrscr();
int a=90, b=100;
fun1(a,b);
cout<<\n<<a<<\n<<b;
fun1(a,b);
cout<<\n<<a<<\n<<b;
}
k. void fun1(int &p, int q=100)
{
int t=p*q;
p+=t;
if( q= =100)
cout<<\n<<p<<\t<<q<<\t<<t;

else
cout<<\n<<p<<\t<<q;
}
void main()
{
clrscr();
int a=90, b=100;
fun1(a);
cout<<\n<<a<<\n<<b;
fun1(a,b);
cout<<\n<<a<<\n<<b;
}
Q2. Find out the syntax error:
a. #includeiostream.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;
40: cout<<higher range<<endl;
}
}
}
b. #include<iostream.h>
void main( )
{
int x, y;
cin>>x;
for( i=0;i<10;i++)
{
if x= = = y
cout<<x+y;
else
cout<<y;
}
}

Você também pode gostar