/Slip no : 1 Write a C++ program
to create a class Worker with data members as Worker_Name, No_of_Hours_worked,
Pay_Rate. Write necessary member functions to calculate and display the salary
of worker. (Use default value for Pay_Rate) */
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
class worker
{
char
name[10];
int hr;
public:
void accept()
{
cout<<"enter
name";
cin>>name;
cout<<"enter
hours";
cin>>hr;
}
void
calculate(int rate=50)
{
cout<<"salary
of worker is Rs."<<(hr*30)*rate;
}
};
void main()
{
worker ob;
clrscr();
ob.accept();
ob.calculate();
getch();
}
what is the output of this program
ReplyDeletesalary of worker is Rs.7592
DeleteOutput
ReplyDeleteIn cpp main function always return 0 or 1 to the operating system hence it always holds int return datatype.
ReplyDeleteCorrect me if I am wrong.
You used int main then return value is compulsory otherwise no...
Delete