Success while compiling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reon
    New Member
    • Feb 2007
    • 80

    Success while compiling

    This is a simple step of success c++ program


    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<string.h>
    class employee
    {
    char name[10][20];
    float sal[10];
    public:
    	void accept();
    	void display_max();
    	void display_min();
    	void display_avg();
    	void count();
    };
    int i;
    void employee::accept()
    {
    cout<<"\nEnter details of 10 employees : ";
    for(i=0;i<3;i++)
    {
    cin>>name[i];
    cin>>sal[i];
    }
    }
    void employee::display_max()
    {
    	int max1;
    	char max2[20];
    	max1=sal[0];
    	strcpy(max2,name[0]);
    	for(i=1;i<3;i++)
    	{
    		if(sal[i]>max1)
    		{
    		max1=sal[i];
    		strcpy(max2,name[i]);
    		}
    	}
    	cout<<"\n\nmax slary=rs " <<max1<<"   ";cout<<max2;
    }
    void employee::display_min()
    {
    int temp1;
    char temp2[20];
    for(i=0;i< 3;i++)
    {
    for(int j=i;j<3;j++)
    {
    if(sal[i]>sal[j])
    {
    temp1=sal[i];
    sal[i]=sal[j];
    sal[j]=temp1;
    strcpy(temp2,name[i]);
    strcpy(name[i],name[j]);
    strcpy(name[j],temp2);
    }
    }
    }
    cout<<"\n\n min sal: rs."<<sal[0]<<" ";cout<<name[0];
    cout<<"\n\nascending order :\n";
    for(i=0;i<3;i++)
    {
    cout<<" name:"<<name[i]<<" salary=rs."<<sal[i]<<endl;
    }
    cout<<"\n\ndescnding order :\n";
    for(i=2;i>=0;i--)
    {
    cout<<" name:"<<name[i]<<" salary=rs."<<sal[i]<<endl;
    }
    
    }
    void employee::display_avg()
    {
    float s=0;
    for(i=0;i<3;i++)
    s+=sal[i];
    cout<<"\n\n average is rs."<<s/3;
    }
    void employee::count()
    {
    int count1=0;
    for(i=0;i<3;i++)
    {
    if(sal[i]>1000)
    count1++;
    }
    cout<<"\n\n  >1000 ="<<count1;
    cout<<"\n\n  <=1000 ="<<3-count1;
    }
    void main()
    {
    clrscr();
    employee e;
    e.accept();
    e.display_max();
    e.display_min();
    e.display_avg();
    e.count();
    getch();
    }
  • reon
    New Member
    • Feb 2007
    • 80

    #2
    anybody can check this out....

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      If it is successful, what is your problem? What question are you asking? What do you need help with?

      Comment

      • reon
        New Member
        • Feb 2007
        • 80

        #4
        ya i tried a lot and atlast find it... so if it might be helpful to others... so i just shared it....

        Comment

        Working...