0% found this document useful (0 votes)
81 views2 pages

Class XI Programming Review

The document provides questions and exercises related to object-oriented programming concepts in C++. Question 1 asks to identify and correct syntactical errors in two code snippets. Question 2 asks to determine the output of two programs involving structures and references. Question 3 asks to determine the minimum and maximum values a random number program could display. Question 4 asks to identify the correct output of a random number program involving arrays. The lab exercises ask to (1) write a function to check if a string is a palindrome, (2) write functions to display diagonal elements of an array and return their sum, and (3) write a program to add times stored in a structure and display the results.

Uploaded by

amishadalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views2 pages

Class XI Programming Review

The document provides questions and exercises related to object-oriented programming concepts in C++. Question 1 asks to identify and correct syntactical errors in two code snippets. Question 2 asks to determine the output of two programs involving structures and references. Question 3 asks to determine the minimum and maximum values a random number program could display. Question 4 asks to identify the correct output of a random number program involving arrays. The lab exercises ask to (1) write a function to check if a string is a palindrome, (2) write functions to display diagonal elements of an array and return their sum, and (3) write a program to add times stored in a structure and display the results.

Uploaded by

amishadalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

HOME ASSIGNMENT 1

TOPIC : Review of class- XI & Object Oriented Programming

Q1. Rewrite the following program after removing the syntactical errors (if any). Underline each correction.
(a)
#include [iostream.h]
class PAYITNOW
{
int Charge;
PUBLIC:
void Raise(){cin>>Charge;}
void Show{cout<<Charge;}
};
void main()
{
PAYITNOW P;
P.Raise();
Show();
}
b)
#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);
}

Q2. Find the output of the following program:

(a) #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;
}
(b) #include <iostream.h>
#include <ctype.h>
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<<Text<<endl;
}
Q3. 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 <iostream.h>
#include <stdlib.h>
void main()
{ int N,Guessme;
randomize();
cin>>N;
Guessme=random(N)+10;
cout<<Guessme<<endl;}
Q4. In the following program, find the correct possible output(s) from the options
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char City [ ] [10] = {DEL, CHN, KOL, BOM, BNG};
int Fly;
for (int I=0;1<3;1++)
{ Fly = random(2)+1;
cout<<City [Fly]<<:;
}
}
outputs:
(i) DEL:CHN:KOL: (ii) CHN:KOL:CHN: (iii) KOL:BOM:BNG: (iv) KOL:CHN:KOL:
LAB EXERCISES 1
TOPIC : Review of class- XI & Object Oriented Programming

LAB 1.1- Write a function to check whether a string is palindrome or not. The function will return y if the passed
string is a palindrome otherwise n will be returned. The prototype of the function is given below:
char palindrome( char string[] );
Now write main() function to declare and obtain a string from the user. Call the above function ( pass the string as an
argument) and display the result.
LAB 1.2 Write a function to display all the elements which lie on two diagonals of a square array. The array and
its size will be passed as arguments. Also find and return the sum of these elements.
Now write main() function to declare and obtain the values of an array of marks from the user. Call the above functions
and display the result.
LAB 1.3. Define a structure time having 3 members hh,mm and ss of integer type. Now write main function to
create 3 variables of time type. Obtain the values of first two variables from the user. The add two times and store it in
3rd variable. Display the contents of all three variables.
Example: Time1 : 2 h 50 m 35 sec and time2 : 3 h 40 m 30 s
Total time : 6 h 31 m 5 s

You might also like