ASSIGNMENT
Chap 1
C++
Revision Tour
1
(a) What is the difference
between Global Variable and Local Variable?
(b) What is the difference between Object Oriented Programming and
Procedural Programming?
© What is the purpose of typedef command?
Explain with example.
(d) Define Run time & Syntax error with
suitable example.
(e) Differentiate between call by value & call
by reference .Give example also.
2
(a) Write the names of the header files to which
the following belong:
(i) strcmp() (ii)
fabs()
(iii) frexp() (iv)
isalnum()
(v) setw() (vi) gets()
(vii) abs() (viii) isupper()
(ix) pow() (x) random()
(xi) isdigit() (xii) clrscr()
(xiii) fabs() (xiv) toupper()
3
(a) Rewrite the following program after removing the syntactical errors
(if any). Underline each correction.
#include
[iostream.h]
class
PAYITNOW
{
int
Charge;
PUBLIC:
void Raise(){cin>>Charge;}
void Show{cout<
};
void
main()
{
PAYITNOW
P;
P.Raise();
Show();
}
(b) Find
the output of the following program:
#include
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<
Calculate(PL);
cout<
Calculate(PL,15);
cout<
}
(c) Find the output of the following
program:
#include
#include
void
Encrypt(char T[])
{
for
(int i=0;T[i]!='\0';i+=2)
if
(T[i]=='A' || T[i]=='E') T[i]='#';
else
if (islower(T[i])) T[i]=toupper(T[i]);
else
T[i]='@';
}
void main()
{
char
Text[]="SaVE EArtH";//The two words in the string Text
//are separated by single space
Encrypt(Text);
cout<
}
(d) In the
following program, if the value of N given by the user is 15, what maximum and
minimum values the program could possibly display?
#include
#include
void main()
{
int N,Guessme;
randomize();
cin>>N;
Guessme=random(N)+10;
cout<
}
(e) Rewrite the following
program after removing the syntactical errors (if any). Underline each
correction.
#include
struct
Pixels
{ int Color,Style;}
void
ShowPoint(Pixels P)
{ cout<
void
main()
{
Pixels Point1=(5,3);
ShowPoint(Point1);
Pixels
Point2=Point1;
Color.Point1+=2;
ShowPoint(Point2);
}
(f) Find the output of the following
program:
#include
void
Changethecontent(int Arr[], int Count)
{
for
(int C=1;C
Arr[C-1]+=Arr[C];
}
void
main()
{
int
A[]={3,4,5},B[]={10,20,30,40},C[]={900,1200};
Changethecontent(A,3);
Changethecontent(B,4);
Changethecontent(C,2);
for
(int L=0;L<3 cout="" span="">3>
cout<
for
(L=0;L<4 cout="" span="">4>
cout<
for
(L=0;L<2 cout="" span="">2>
}
(g) Find the output of the
following program:
#include
struct
Game
{
char
Magic[20];int Score;
};
void
main()
{
Game
M={“Tiger”,500};
char
*Choice;
Choice=M.Magic;
Choice[4]=’P’;
Choice[2]=’L’;
M.Score+=50;
cout<
Game N=M;
N.Magic[0]=’A’;N.Magic[3]=’J’;
N.Score-=120;
cout<
}
(h) Find the output of the following
program:
#include
#include
void main()
{
int a,b,c,d,e;
c=1;
a=5,b=5;
switch(c)
{
case 1:
d=a+b;
break;
case 2:
d=a-b;
}
cout<
}
(i) Find the output of the following
program:
#include
main()
{
int a,b,c,d,j,x,i;
for (i=0;i<=5;i++)
for
(j=1;j<=1;j++)
{
cout<
}
return 0;
}
No comments:
Post a Comment