fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class employee
  5. {
  6. char name [50];
  7. char designation[20];
  8. float basic , gross;
  9. public :
  10. void accept();
  11. void display();
  12. friend void calculated (employee); //friend function declaration
  13.  
  14. };
  15.  
  16. void employee ::accept ()
  17.  
  18. {
  19. cout<<"enter name, designation , basic salary ";
  20. cin>>name>>designation>>basic ;
  21. }
  22.  
  23. void calculated (employee e )
  24.  
  25. {
  26. e.gross= e.basic + 0.5* e.basic+ 0.9*e.basic;
  27.  
  28. cout<<"gross salary is "<<e.gross;
  29.  
  30. }
  31.  
  32.  
  33. display()
  34. {
  35. cout<<"name is "<<e::name<<endl;
  36. cout<<"designation"<<e::designation<<endl;
  37. cout<<"basic salary"<<e::basic<<endl;
  38. }
  39.  
  40. int main ()
  41. {
  42. employee e ;
  43. e.accept();
  44. e.dipslay();
  45. calculated (a,b);
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0.02s 26000KB
stdin
Standard input is empty
stdout
#include<iostream>
using namespace std;

class employee
{
	char name [50];
	char designation[20];
	float basic , gross;
	public :
	void accept();
	void display();
	friend void calculated (employee);                             //friend function declaration 
		
};

void employee ::accept ()

{
  cout<<"enter name, designation , basic salary ";
  cin>>name>>designation>>basic ;
}

void calculated (employee e )

{
    e.gross= e.basic +	0.5* e.basic+ 0.9*e.basic;
    
    cout<<"gross salary is "<<e.gross;
	
}


display()
{
	cout<<"name is "<<e::name<<endl;
	cout<<"designation"<<e::designation<<endl;
	cout<<"basic salary"<<e::basic<<endl;
}

int main ()
{
	employee e ;
	e.accept();
	e.dipslay();
    calculated (a,b);
	return 0; 
}