Professional Documents
Culture Documents
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);
}
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