Chapter – 2. STRUCTURES

2005 Outside Delhi:

1.d. Find the output of the following program:

#include<iostream.h>
struct Package
int Length,Breadth,Height; { };
void Occupies(Package M)
{
cout<<M.Length<<”x”<<M.Breadth<<”x”;
cout<<M.Height<<endl;
}
void main( )
{
Package P1={100,150,50},P2,P3;
++P1.Height; Occupies(P1);
P3=P1; ++P3.Lengh; P3.Breadth++;
Occupies(P3);
P2=P3; P2.Height+=50;
P2.Length--;
Occupies(P2);
}

Output:
100 x 150 x 51
101 x 151 x 51
100 x 151 x 101

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;
}