Headlines
Loading...
Write a C++ program to implement static data members and static member functions, concept of const functions.

Write a C++ program to implement static data members and static member functions, concept of const functions.

PROGRAM:Write a C++ program to implement static data members and static member functions, concept of const functions.

#include <iostream.h>
#include<conio.h>
class employee
{
   char name [30];
   float bs;
   static float S;

public  : 
void read()
{
cout <<"\n\n Enter name  :  ";
cin>>name;
cout<<"\n Enter basic sal  :  ";
cin >>bs;
S = S+bs;
}
void show()
{
cout<<name<<"\t"<<bs<<"\n";
}

static void avg_sal()
{
float avg = S/3;
cout<<"www.adkool.com";
cout <<"\n Avg Sal  :  "<<avg;
}
};

float employee  : : S;

void main ()
{
clrscr();
employee A,B,C;
A.read ();
B.read();
C.read();
        cout<<"www.adkool.com";
cout <<"\n\n+Employee list \n";
cout <<"\n---------------------\n";
cout <<"\nNAME \tBASIC_SAL\n";
cout <<"---------------------\n";
        cout<<"www.adkool.com";

A.show();
B.show();
C.show ();

employee :: avg_sal();
getch();
}

OUTPUT

Enter name  :  AAA                                                               
 Enter basic sal  :  2000                
Enter name  :  BBB                                                               
Enter basic sal  :  3000                                                         
 Enter name  :  CCC                                                               
 Enter basic sal  :  4000                                                       
 +Employee list                                                                  
                                                                                
---------------------                                                           
                                                                                
NAME    BASIC_SAL                                                               
---------------------                                                           
AAA     2000                                                                    
BBB     3000                                                                    
CCC     4000                                                                    
                                                                                
 Avg Sal  :  3000      

*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***