Chapter – 2. STRUCTURES

Ans:

#include<iostream.h>
#include<stdio.h>
void main( )
{
struct movie
{
char movie_name[20];
char movie_type;
int ticket_cost;
//Initialization of variables inside a structure is not allowed.
}
MOVIE;
gets(MOVIE.movie_name);
cin>>MOVIE.movie_type;
//A single character cannot be read using gets
}

2005 Delhi:

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

#include<iostream.h>
struct MyBox
{
int Length,Breadth,Height;
};
void Dimension(MyBox M)
{
cout<<M.Length<<”x”<<M.Breadth<<”x”;
cout<<M.Height<<endl;
}
void main( )
{
MyBox B1={10,15,5},B2,B3;
++B1.Height;
Dimension(B1);
B3=B1;
++B3.Length;
B3.Breadth++;
Dimension(B3);
B2=B3; B2.
Height+=5;
B2.Length--;
Dimension(B2);
}

Output:
10 x 15 x 6
11 x 16 x 6
10 x 16 x 11


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter2_c.php on line 127

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter2_c.php on line 127

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter2_c.php on line 129

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter2_c.php on line 129