Structure
[SET – 1]
1
|
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=Z; Y.C+=10; Y.R+=20; Z.C-=15; Display(X); Display(Y); Display(Z); } |
2
|
Find the output of the following program:
#include <iostream.h> struct PLAY { int Score, Bonus; }; void Calculate(PLAY &P, int N=10) { P.Score++; P.Bonus+=N; } void main() { PLAY PL={10,15}; Calculate(PL,5); cout<<PL.Score<<”:”<<PL.Bonus<<endl; Calculate(PL); cout<<PL.Score<<”:”<<PL.Bonus<<endl; Calculate(PL,15); cout<<PL.Score<<”:”<<PL.Bonus<<endl; } |
3
|
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); } |
4
|
Rewrite the following program after removing the syntactical errors (if any). Underline each correction.
#include <iostream.h> struct Pixels { int Color, Style; } void ShowPoint(Pixels P) { cout<<P.Color,P.Style<<endl; } void main() { Pixels Point1=(5,3); ShowPoint(Point1); Pixels Point2=Point1; Color.Point1+=2; ShowPoint(Point2); } |
5
|
Declare a structure to represent a complex number (a number having a real part and imaginary part). Write C++ functions to add, subtract, multiply and divide two complex numbers.
|
6
|
An array stores details of 25 students (rollno, name, marks in three subject). Write a program to create such an array and print out a list of students who have failed in more than one subject.
|
No comments:
Post a Comment