Skip to content

Instantly share code, notes, and snippets.

@swaaz
Last active February 19, 2020 04:43
Show Gist options
  • Save swaaz/b96485406b2a1c4f63781e4a83f66fcc to your computer and use it in GitHub Desktop.
Save swaaz/b96485406b2a1c4f63781e4a83f66fcc to your computer and use it in GitHub Desktop.
apti-cpp
#include <iostream>
using namespace std;
class student{
public: int reg;
string name;
void display();
void read();
private:void display1()
{
cout<<"reg-1:"<<reg+10<<endl;
}
};
void student::display()
{
cout<<"reg:"<<reg<<endl;
display1();
}
void student::read()
{
cout<<"enter data\n";
cin>>reg;
}
int main()
{
student s[2];
for(int i=0;i<2;i++){
s[i].read();
s[i].display();
}
}
#include <iostream>
using namespace std;
class A{
public: int x;
float y;
void display();
};
void A::display()
{
x=1;
y=7.2;
cout<<"x & y"<<x<<endl<<y<<endl;
}
int main()
{
A a;
a.display();
}
#include <iostream>
using namespace std;
class A{
public: int x;
float y;
void display() const;
};
void A::display() const
{
// x=1;
// y=7.2;
cout<<"x & y"<<x<<endl<<y<<endl;
}
int main()
{
A a;
a.x=10;
a.y=11;
a.display();
}
#include <iostream>
using namespace std;
class A{
public:
mutable int x;
mutable float y;
void display() const;
};
void A::display() const
{
x=1;
y=7.2;
cout<<"x & y"<<x<<endl<<y<<endl;
}
int main()
{
A a;
// a.x=10;
//a.y=11;
a.display();
}
#include <iostream>
using namespace std;
class Employee{
public: int eno;
string ename;
float salary,da,it,gross,nsalary;
void read();
void compute();
void display();
};
void Employee::read()
{
cout<<"Enter eno,enmae,salary"<<endl;
cin>>eno>>ename>>salary;
}
void Employee::compute()
{
da=(52/100) *salary;
gross=salary+da;
it=(30/100)*gross;
nsalary=salary+da-it;
}
void Employee::display()
{
cout<<"Name:"<<ename<<endl;
cout<<"eno:" <<eno<<endl;
cout<<"salary:"<<salary;
cout<<"da:"<<da;
//cout<<"it"<<endl<it;
cout<<"gross"<<endl<<gross;
cout<<"net salary"<<endl<<nsalary;
}
int main()
{
Employee emp[10];
int n=2;
cout<<"Enter details"<<endl;
for(int i=0;i<2;i++)
{
emp[i].read();
emp[i].compute();
}
for(int i=0;i<2;i++) emp[i].display() ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment