Skip to content

Instantly share code, notes, and snippets.

@iamshouvikmitra
Last active January 12, 2017 18:56
Show Gist options
  • Save iamshouvikmitra/3336b84e50164f35e57d24ec71aadfbc to your computer and use it in GitHub Desktop.
Save iamshouvikmitra/3336b84e50164f35e57d24ec71aadfbc to your computer and use it in GitHub Desktop.
create a class private: Name, Roll no Protected: Subject, Branch, class Public: Function "sum" to add 5 subject marks Function show to show the marks in total
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
class Main
{
private:
char Name[20];
int roll;
protected:
int subject;
char branch;
char Class;
public:
int a, b, c, d, e, sum;
int add()
{
cout<<"Performing addition";
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
}
void show()
{
cout<<sum;
}
};
int main()
{
Main obj;
obj.add();
obj.show();
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment