2.c) Give the output of the following program:
#include<iostream.h> #include<string.h>
class per
{ char name[20];
float salary;
public:
per(char *s, float a)
{ strcpy(name,s);
salary=a;
}
per *GR(per &x)
{ if(x.salary>=salary)
return &x;
else
return this;
}
void display( )
{ cout<<”Name:“<<name<<”\n”;
cout<<”Salary:“<<salary<<”\n”;
}
};
void main( )
{ Per P1(“REEMA”,10000),
P2(“KRISHNAN”,20000),
P3(“GEORGE”,5000);
per *P;
P=P1.GR(P3);P->display( );
P=P2.GR(P3);P->display( ); }
4
1999:
1.d) Give the output of the following program.
#include<stdio.h>
void main( )
{ char *p=”Difficult”;
char c; c=*p++; printf(“%c”,c);
}
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )