2004 :
1.c) Rewrite the corrected code for the
following program. Underline each correction
if any.
#include<iostream.h>
structure Supergym
{ int member number;
char membername[20];
char membertype[]=”HIG”;
};
void main( )
{ Supergym person1,person2;
cin>>”Member Number: “;
cin>>person1.membhernumber;
cout<<”Member Name: “;
cin>>person1.membername;
person1.member type = “MIG”;
person2=person1;
cin>>”Member Number;“ <<person2.membernumber;
cin<<”Member Name” <<person2.membername;
cin<<”Member Number:”<<person2.membertype;
}
Ans:
#include<iostream.h>
#include<string.h>
struct Supergym{ int membernumber;
char membername[20];
char membertype[4];
};
void main( )
{ Supergym person1,person2;
cin>>"Member Number: ";
cin>>person1.membernumber;
cout<<"Member Name: ";
cin>>person1.membername;
strcpy(person1.membertype,"MIG");
person2=person1;
cin>>"Member Number;" >>person2.membernumber;
cin>>"Member Name" >>person2.membername;
cin>>"Member Number:" >>person2.membertype;
}
2003 :
1.d) Give the output of the following program:
#include<iostream.h>
struct Pixel
{ int C,R;
};
void Display(Pixel P)
{
cout<<”col”<<P.C<<”Row”<<P.R<<endl ;
}
void main( )
{
Pixel X={40,50},Y,Z;
Z=X;
X.C+=10;
Y=X;
Y.R+=20;
Z.C-=15;
Display(X);
Display(Y);
Display(Z); }
2001 :
1.e) Give the output of the following program.
3
#include<iostream.h>
#include<conio.h>
int g=20;
void func(int &x,int y)
{ x=x-y;
y=x*10;
cout<<x<<’,’<<y<<’\n’;
}
void main( )
{ int g=7;
func(g,::g);
cout<<g<<’,’<<::g<<’\n’;
func(::g,g);
cout<<g<<’,’<<::g<<’\n’;
}“If wealth is lost,
nothing is lost
If health is lost,
something is lost
If character is lost,
everything is lost”
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )