├── Commandline.cpp ├── Convert.cpp ├── DoubleLL.cpp ├── Expt_1_1.cpp ├── Expt_1_2.cpp ├── Expt_2_1_1.cpp ├── Expt_2_1_2.cpp ├── Expt_2_2.cpp ├── Expt_2_3.cpp ├── Expt_3_1.cpp ├── Expt_3_2.cpp ├── Expt_3_3.cpp ├── Expt_4_1_1.cpp ├── Expt_4_1_2.cpp ├── Independence.txt ├── Inheritance.cpp ├── Inheritance ├── single_private.cpp ├── single_protected.cpp └── single_public.cpp ├── README.md ├── bestgenericfunction.cpp ├── binaryclass.cpp ├── binaryfile.cpp ├── binarytree.cpp ├── binarytrees.cpp ├── class.cpp ├── class1.cpp ├── class_write_basic.cpp ├── constructor.cpp ├── copycons (1).cpp ├── copycons.cpp ├── defaultarg.cpp ├── destructor.cpp ├── dynamic.cpp ├── file_write_basic.txt ├── friendone.cpp ├── friendtwo.cpp ├── functionoverload.cpp ├── genfunc_twotypes.cpp ├── graph1.cpp ├── hybridex.cpp ├── hybridvirtual.cpp ├── independence.cpp ├── inheritance.cpp ├── init_nocons.cpp ├── inline.cpp ├── linkedmain.cpp ├── multilevel.cpp ├── multipleambiguity.cpp ├── object_argunment.cpp ├── pub_pri_call.cpp ├── read_file_basic.cpp ├── read_write_basic.cpp ├── sampleprogram.cpp ├── single_private.cpp ├── single_protected.cpp ├── single_public.cpp ├── static.cpp ├── string.cpp └── write_file_basic.cpp /Commandline.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(int argc,char *argv[]) 4 | { 5 | int i=1; 6 | cout<<"The name of the file is"< 2 | using namespace std; 3 | int main() 4 | { 5 | int n,m,i,j,k,count=0; 6 | cin>>n>>m; 7 | k=n*m; 8 | int arr1[n][m]; 9 | int arr2[k]; 10 | for(i=0;i>arr1[i][j]; 15 | } 16 | } 17 | for(i=0;i 2 | using namespace std; 3 | class student 4 | { 5 | public: 6 | string rollno; 7 | string sapid; 8 | string name; 9 | string specialization; 10 | student *next; 11 | student *prev; 12 | student() 13 | { 14 | rollno="R171217041"; 15 | sapid="500060720"; 16 | name="Nishkarsh Raj Khare"; 17 | specialization="DevOps"; 18 | } 19 | void insert() 20 | { 21 | cout<<"Enter the name of the person"<>name; 23 | cout<<"Enter the sapid of the student"<>sapid; 25 | cout<<"Enter the rollno of the student"<>rollno; 27 | cout<<"Enter the Specialization of the student"<>specialization; 29 | } 30 | void show() 31 | { 32 | cout<<"Name of the student is :"<insert(); 46 | node->next=NULL; 47 | node->prev=NULL; 48 | cout<<"Lets see the details of first node"<show(); 50 | start=node; 51 | string n,n2; 52 | int flag=0; 53 | int quit=0,choice; 54 | do 55 | { 56 | cout<<"\t\t\t\tOption Menu\n\n"<>choice; 68 | switch(choice) 69 | { 70 | case 1: cout<<"Insertion at Beginning"<insert(); 73 | start->prev=ptr; 74 | ptr->next=start; 75 | ptr->prev=NULL; 76 | start=ptr; 77 | break; 78 | case 2: cout<<"Insertion at End"<insert(); 81 | node->next=NULL; 82 | for(ptr=start;ptr->next!=NULL;ptr=ptr->next); 83 | ptr->next=node; 84 | node->prev=ptr; 85 | break; 86 | case 3: cout<<"Insertion at any point"<>n; 89 | for(ptr=start;ptr!=NULL;ptr=ptr->next) 90 | { 91 | if(ptr->name==n) 92 | break; 93 | } 94 | node=new student; 95 | node->insert(); 96 | p=ptr->next; 97 | node->next=ptr->next; 98 | node->prev=p->prev; 99 | ptr->next=node; 100 | break; 101 | case 4: cout<<"Deletion at beginning"<next; 104 | delete ptr; 105 | break; 106 | case 5: cout<<"Deletion at End"<next!=NULL;p=ptr,ptr=ptr->next); 108 | delete ptr; 109 | p->next=NULL; 110 | break; 111 | case 6: cout<<"Deletion anywhere"<>n2; 114 | for(ptr=start;ptr->next!=NULL;p=ptr,ptr=ptr->next) 115 | { 116 | if(ptr->name==n2) 117 | { 118 | flag=1; 119 | break; 120 | } 121 | if(flag==1) 122 | { 123 | cout<<"Record Does not exist"<next=ptr->next; 128 | delete ptr; 129 | } 130 | } 131 | break; 132 | case 7: cout<<"Traversal from start"<next) 134 | ptr->show(); 135 | break; 136 | case 8: cout<<"Traversal from the end"<next!=NULL;ptr=ptr->next); 138 | for(;ptr!=NULL;ptr=ptr->prev) 139 | { 140 | ptr->show(); 141 | } 142 | break; 143 | case 9: quit=1; 144 | break; 145 | default: cout<<"Wrong Choice! Please Try Again"< 2 | using namespace std; 3 | class lenght1 //unlike main its not allowed to make variable declarations within member functions/ 4 | { 5 | float lenght; 6 | float l1; 7 | public: 8 | void setlenght(float l) 9 | { 10 | lenght=l; 11 | } 12 | void convert() 13 | { 14 | if(lenght>12) 15 | { 16 | l1=(int)lenght/12; 17 | lenght=int(lenght)%12; //note that float does not allow mod function to work upon 18 | } 19 | cout<<"Lenght is "<>l; 28 | lenght1 obj; 29 | obj.setlenght(l); 30 | obj.convert(); 31 | cout< 2 | using namespace std; 3 | class Queue 4 | { 5 | public: //all public needed to access outside in main 6 | string name; 7 | int roll_number; 8 | double total_marks; 9 | Queue *next; 10 | void show() 11 | { 12 | cout<>node->name; 23 | cout<<"Enter the roll number of this person"<>node->roll_number; 25 | cout<<"Enter the total marks of this person"<>node->total_marks; 27 | node->next=NULL; 28 | front=node; 29 | rear=node; 30 | node->show(); 31 | cout<>ch; 43 | switch(ch) 44 | { 45 | case 1: cout<<"Insertion at end"<>p->name; 49 | cout<<"Enter the roll number of this person"<>p->roll_number; 51 | cout<<"Enter the total marks of this person"<>p->total_marks; 53 | rear->next=p; 54 | p->next=NULL; 55 | rear=p; 56 | break; 57 | case 2: cout<<"Deletion at beginning"<show(); 60 | ptr=front; 61 | front=front->next; 62 | delete ptr; 63 | break; 64 | case 3: cout<<"Traversal"<next) 66 | { 67 | int i=1; 68 | cout<<"The "<show(); 70 | } 71 | break; 72 | case 4: quit=1; 73 | break; 74 | default: cout<<"Wrong Choice! Try again"< 2 | using namespace std; 3 | class lenght1 //unlike main its not allowed to make variable declarations within member functions/ 4 | { 5 | float lenght; 6 | float l1; 7 | public: 8 | lenght1() 9 | { 10 | lenght=100; 11 | l1=50; 12 | } 13 | ~lenght1() 14 | { 15 | cout<<"Object Destroyed"<12) 24 | { 25 | l1=(int)lenght/12; 26 | lenght=int(lenght)%12; //note that float does not allow mod function to work upon 27 | } 28 | cout<<"Lenght is "<>l; 37 | lenght1 obj; 38 | obj.setlenght(l); 39 | obj.convert(); 40 | cout< 2 | using namespace std; 3 | class Queue 4 | { 5 | public: //all public needed to access outside in main 6 | string name; 7 | int roll_number; 8 | double total_marks; 9 | Queue *next; 10 | Queue() 11 | { 12 | name="Nishkarsh"; 13 | roll_number=41; 14 | total_marks=256.60; 15 | } 16 | ~Queue() 17 | { 18 | cout<<"Object Destroyed"<>node->name; 33 | cout<<"Enter the roll number of this person"<>node->roll_number; 35 | cout<<"Enter the total marks of this person"<>node->total_marks; 37 | node->next=NULL; 38 | front=node; 39 | rear=node; 40 | node->show(); 41 | cout<>ch; 53 | switch(ch) 54 | { 55 | case 1: cout<<"Insertion at end"<>p->name; 59 | cout<<"Enter the roll number of this person"<>p->roll_number; 61 | cout<<"Enter the total marks of this person"<>p->total_marks; 63 | rear->next=p; 64 | p->next=NULL; 65 | rear=p; 66 | break; 67 | case 2: cout<<"Deletion at beginning"<show(); 70 | ptr=front; 71 | front=front->next; 72 | delete ptr; 73 | break; 74 | case 3: cout<<"Traversal"<next) 76 | { 77 | int i=1; 78 | cout<<"The "<show(); 80 | } 81 | break; 82 | case 4: quit=1; 83 | break; 84 | default: cout<<"Wrong Choice! Try again"< 2 | using namespace std; 3 | class WWE 4 | { 5 | string name; 6 | float salary; 7 | string nickname; 8 | public: 9 | WWE() 10 | { 11 | name="Seth Rollins"; 12 | salary=2000000; 13 | nickname="The Architect"; 14 | } 15 | ~WWE() 16 | { 17 | cout<<"Object Destroyed"< 2 | using namespace std; 3 | class Stack 4 | { 5 | public: //all public needed to access outside in main 6 | string name; 7 | int roll_number; 8 | double total_marks; 9 | Stack *next; 10 | void show() 11 | { 12 | cout<>node->name; 23 | cout<<"Enter the roll number of this person"<>node->roll_number; 25 | cout<<"Enter the total marks of this person"<>node->total_marks; 27 | node->next=NULL; 28 | top=node; 29 | node->show(); 30 | cout<>ch; 42 | switch(ch) 43 | { 44 | case 1: cout<<"Insertion at end"<>p->name; 48 | cout<<"Enter the roll number of this person"<>p->roll_number; 50 | cout<<"Enter the total marks of this person"<>p->total_marks; 52 | p->next=top; 53 | top=p; 54 | break; 55 | case 2: cout<<"Deletion at End"<show(); 59 | top=top->next; 60 | delete ptr; 61 | break; 62 | case 3: cout<<"Traversal"<next) 64 | { 65 | int i=1; 66 | cout<<"The "<show(); 68 | } 69 | break; 70 | case 4: quit=1; 71 | break; 72 | default: cout<<"Wrong Choice! Try again"< 2 | using namespace std; 3 | class hydrogen; 4 | class sulphur; 5 | class oxygen; 6 | class oxygen 7 | { 8 | public: 9 | int mass; 10 | oxygen() 11 | { 12 | mass=64; 13 | } 14 | void input(int m) 15 | { 16 | mass=m; 17 | } 18 | friend void empiricalmass(oxygen o,hydrogen h,sulphur s); 19 | }; 20 | class hydrogen 21 | { 22 | public: 23 | int mass; 24 | hydrogen() 25 | { 26 | mass=2; 27 | } 28 | void input(int m) 29 | { 30 | mass=m; 31 | } 32 | friend void empiricalmass(oxygen o,hydrogen h,sulphur s); 33 | }; 34 | class sulphur 35 | { 36 | public: 37 | int mass; 38 | sulphur() 39 | { 40 | mass=32; 41 | } 42 | void input(int m) 43 | { 44 | mass=m; 45 | } 46 | friend void empiricalmass(oxygen o,hydrogen h,sulphur s); 47 | }; 48 | void empiricalmass(oxygen o,hydrogen h,sulphur s) 49 | { 50 | int x,y,z; 51 | float n1,n2,n3; 52 | cout<<"Lets see the masses you have entered"<>x; 66 | cout<<"Enter the number of moles of hydrogen "<>y; 68 | cout<<"Enter the number of moles of sulphur "<>z; 70 | cout<<"The Emperical mass of oxygen, hydrogen and sulphur compounds is H"<>x; 78 | cout<<"Enter the mass of Hydrogen in grams"<>y; 80 | cout<<"Enter the mass of Sulphur in grams"<>z; 82 | oxygen o; 83 | o.input(x); 84 | sulphur s; 85 | s.input(z); 86 | hydrogen h; 87 | h.input(y); 88 | empiricalmass(o,h,s); 89 | cout<<"Goodbye"< 2 | #include 3 | using namespace std; 4 | class shape 5 | { 6 | float l,b; 7 | public: 8 | shape() 9 | { 10 | l=10; 11 | b=20; 12 | } 13 | virtual void calculate_area() 14 | { 15 | cout<<"Area of Shape"<>ch; 84 | switch(ch) 85 | { 86 | case 1: 87 | p=&r; 88 | cout<<"Rectangle"<>l>>b; 91 | r.input(l,b); 92 | p->calculate_area(); 93 | break; 94 | case 2: 95 | p=&t; 96 | cout<<"Triangle"<>s1>>s2>>s3; 99 | t.input(s1,s2,s3); 100 | p->calculate_area(); 101 | break; 102 | case 3: cout<<"Exit please"< 2 | using namespace std; 3 | class student 4 | { 5 | protected: 6 | string name,rollno,gender; 7 | public: 8 | student() 9 | { 10 | name="Nishkarsh Raj"; 11 | rollno="R171217041"; 12 | gender="Male"; 13 | } 14 | void student_details(string s1,string s2, string s3) 15 | { 16 | name=s1; 17 | rollno=s2; 18 | gender=s3; 19 | } 20 | void display_student_details() 21 | { 22 | cout<<"Details of the student are"<>gender; 101 | student s; 102 | s.student_details(name,roll,gender); 103 | cout<<"Enter the marks of student in internals 6 subject out of 30"<>marks[i]; 109 | } 110 | cout<<"Enter the marks of student in Externals 6 subject out of 70"<>marks1[i]; 115 | } 116 | internal_marks i1; 117 | i1.get_marks(marks); 118 | external_marks e; 119 | e.get_marks(marks1); 120 | result r; 121 | //////////////////////////////////// 122 | cout<<"Lets see the result of the student"< 2 | using namespace std; 3 | class location 4 | { 5 | public: 6 | int latitude,longitude; 7 | location() 8 | { 9 | latitude=10; 10 | longitude=25; 11 | } 12 | location(int x,int y) 13 | { 14 | latitude=x; 15 | longitude=y; 16 | } 17 | void show() 18 | { 19 | cout<<"Longitude of the location is "< 2 | using namespace std; 3 | class location 4 | { 5 | int latitude,longitude; 6 | public: location() 7 | { 8 | latitude=25; 9 | longitude=20; 10 | } 11 | location(int x,int y) 12 | { 13 | latitude=x; 14 | longitude=y; 15 | } 16 | void show() 17 | { 18 | cout<<"Latitude of the location is "< 2 | using namespace std; 3 | class WWE 4 | { 5 | int serial; 6 | public: 7 | string name; 8 | float salary; 9 | WWE() 10 | { 11 | serial=1; 12 | name="Finn Balor"; 13 | salary=40000; 14 | } 15 | void insert() 16 | { 17 | cout<<"Make the entries of the superstar"<>serial; 20 | cout<>name; 23 | cout<>salary; 26 | cout< 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: private base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | //cout<<"Protected Member of base "< 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: protected base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | cout<<"Protected Member of base "< 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: public base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | cout<<"Protected Member of base "< 2 | #include 3 | using namespace std; 4 | template 5 | void sort(X *arr,int size) //generic sort 6 | { 7 | int i,j; 8 | X temp; 9 | for(i=0;i //generic insertions 23 | void insert(Y *arr,int size) 24 | { 25 | int i; 26 | cout<<"Lets make the insertions now"<>arr[i]; 31 | } 32 | } 33 | template //generic display 34 | void display(Z *arr,int size) 35 | { 36 | int i; 37 | cout<<"Sorted array is now being displayed"<>n; 49 | int A[n]; 50 | float B[n]; 51 | char C[n]; 52 | do 53 | { 54 | cout<<"Option Menu"<>ch; 61 | switch(ch) 62 | /*Note that you cannot declare arrays inside switch*/ 63 | { 64 | case 1: 65 | insert(A,n); 66 | sort(A,n); 67 | display(A,n); 68 | break; 69 | case 2: 70 | insert(B,n); 71 | sort(B,n); 72 | display(B,n); 73 | break; 74 | case 3: 75 | insert(C,n); 76 | sort(C,n); 77 | display(C,n); 78 | break; 79 | case 4: quit=1; 80 | break; 81 | default: cout<<"Wrong Choice"< 2 | #include 3 | using namespace std; 4 | class student 5 | { 6 | int roll; 7 | string name; 8 | public: 9 | student() 10 | { 11 | roll=41; 12 | name="Nishkarsh Raj Khare"; 13 | } 14 | void insert() 15 | { 16 | cout<<"Lets insert the value"<>roll; 21 | } 22 | void show() 23 | { 24 | cout<<"Name of the student is "< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | cout<<"Binary files!"<>ch; 17 | switch(ch) 18 | { 19 | case 1: 20 | cout<<"Enter the number you want to enter to the file"<>num; 22 | nish.write((char*)&num,sizeof(num)); 23 | break; 24 | case 2: quit=1; 25 | break; 26 | } 27 | k++; 28 | }while(quit!=1); 29 | nish.close(); 30 | cout<<"Writing Over! Lets see what you have inserted"< 2 | using namespace std; 3 | class human 4 | { 5 | public: 6 | string name; 7 | int age; 8 | string sex; 9 | string DOB; 10 | human *left; //left child 11 | human *right; //right child 12 | human() 13 | { 14 | name="Maya Rani Khare"; 15 | age=76; 16 | sex="Female"; 17 | DOB="18/11/1941"; 18 | } 19 | void insert() 20 | { 21 | cout<<"Enter the name of the person"<>age; 25 | cout<<"Enter the sex of the person"<>sex; 27 | cout<<"Enter the DOB of the person"<>DOB; 29 | } 30 | void show() 31 | { 32 | cout<<"Name of the person is "<insert(); 45 | node->left=NULL; 46 | node->right=NULL; 47 | root=node; 48 | cout<<"Lets see the root details of the Family"<show(); 50 | return 0; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /binarytrees.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | //create a binary tree for a person having two people he trusts the most starting with yourself 6 | //here left is most trusted and right is second most trusted 7 | class person 8 | { 9 | public: 10 | int keyid; 11 | string name,gender,contact_number; 12 | person *left; 13 | person *right; 14 | person() 15 | { 16 | name="Nishkarsh Raj Khare"; 17 | gender="Male"; 18 | contact_number="9005445752"; 19 | } 20 | void insert() 21 | { 22 | cout<<"Enter key id of the person"<>keyid; 24 | cout<<"Enter name of the person (Only First Name)"<>name; 26 | cout<<"Enter the gender of the person"<>gender; 28 | cout<<"Enter the contact number of the person"<>contact_number; 30 | } 31 | void show() 32 | { 33 | cout<<"The key ID of the person is "<left!=NULL) 64 | { 65 | lheight=height(node->left); 66 | } 67 | if(node->right!=NULL) 68 | { 69 | rheight=height(node->right); 70 | } 71 | if(lheight>rheight) 72 | return(lheight+1); 73 | else 74 | return(rheight+1); 75 | } 76 | } 77 | void printgivenlevel(person *node,int level) 78 | { 79 | if(node==NULL) 80 | { 81 | return; 82 | } 83 | if(level==1) 84 | { 85 | node->show(); 86 | } 87 | else if(level>1) 88 | { 89 | printgivenlevel(node->left,level-1); 90 | printgivenlevel(node->right,level-1); 91 | } 92 | } 93 | void print_inorder(person *node) 94 | { 95 | if(node->left!=NULL) 96 | print_inorder(node->left); 97 | node->show(); 98 | if(node->right!=NULL) 99 | print_inorder(node->right); 100 | } 101 | void print_preorder(person *node) 102 | { 103 | node->show(); 104 | if(node->left!=NULL) 105 | print_preorder(node->left); 106 | if(node->right!=NULL) 107 | print_preorder(node->right); 108 | } 109 | void print_postorder(person *node) 110 | { 111 | if(node->left!=NULL) 112 | print_postorder(node->left); 113 | if(node->right!=NULL) 114 | print_postorder(node->right); 115 | node->show(); 116 | } 117 | int main() 118 | { 119 | person *node,*root,*ptr,*p1,*p2; 120 | root=NULL; 121 | int i,quit=0; 122 | char reply; 123 | string name; 124 | cout<<"Welcome to the first ever program of Binary Trees done by Nishkarsh Raj Khare"<>reply; 133 | if((reply=='y')||(reply=='Y')) 134 | { 135 | for(i=0;i<50000;i++) 136 | { 137 | cout<<"Please Wait!!! Loading Boot files of the program into the Active Memory case number "<=10000)&&(i<40000)) 143 | { 144 | cout<<"Processing the files and Optimising Disk Space"<>choice; 166 | switch(choice) 167 | { 168 | case 1: cout<<"Creation of Roots"<insert(); 179 | node->left=NULL; 180 | node->right=NULL; 181 | cout<<"Lets See the root of the Tree"<show(); 183 | root=node; 184 | } 185 | break; 186 | case 2: cout<<"Insertion of nodes"<left==NULL)&&(root->right==NULL)) 194 | { 195 | cout<<"Both the left and right sides of the root are free to be filled"<left!=NULL)&&(root->right==NULL)) 198 | { 199 | cout<<"Right side of the root is free to be filled"<left==NULL)&&(root->right!=NULL)) 202 | { 203 | cout<<"Left side of the root is free to be filled"<left!=NULL)&&(root->right!=NULL)) 206 | { 207 | cout<<"Both the sides of root are filled"<>cc; 215 | system("clear"); 216 | switch(cc) 217 | { 218 | case 1: if(root->left!=NULL) 219 | cout<<"Left of the root is filled! Please keep a check"<insert(); 225 | p1->left=NULL; 226 | p1->right=NULL; 227 | root->left=p1; 228 | } 229 | break; 230 | case 2: 231 | if(root->right!=NULL) 232 | cout<<"Right of the root is filled! Please keep a check"<insert(); 238 | p2->left=NULL; 239 | p2->right=NULL; 240 | root->right=p2; 241 | } 242 | break; 243 | default: cout<<"Please improve your Eyesight"< 2 | #include 3 | class employee 4 | { 5 | int emp_id; 6 | string emp_name[20]; 7 | public: 8 | void read(int a,string n) 9 | { 10 | emp_id=a; 11 | emp_name=n; 12 | } 13 | friend void show(employee E); 14 | }; 15 | void show(employee E) 16 | { 17 | cout<<"Name of the employee is "< 2 | #include 3 | using namespace std; 4 | class student 5 | { 6 | string student_name; 7 | int roll_no; 8 | int SAP_ID; 9 | string Specialisation; 10 | public: 11 | void Read_data() 12 | { 13 | cout<<"Enter Student's Name"<>student_name; 15 | cout<<"Enter Roll number of student"<>roll_no; 17 | cout<<"Enter SAP_ID of the student"<>SAP_ID; 19 | cout<<"Enter the Specialisation of the student"<>Specialisation; 21 | } 22 | void show() 23 | { 24 | cout<<"Name of the student is "< 2 | #include 3 | using namespace std; 4 | class nishkarsh 5 | { 6 | public: 7 | int roll; //if these are private data members how will they be accessed in main so that they can be stored inside the file?? 8 | string name; 9 | void insert(int r,string n) 10 | { 11 | roll=r; 12 | name=n; 13 | } 14 | void show() 15 | { 16 | cout<<"Name is "<>r>>n; 28 | n1.insert(r,n); 29 | n1.show(); 30 | cout<<"Class has been created"<>n2>>r2; 41 | nishkarsh o; 42 | o.insert(r2,n2); 43 | o.show(); 44 | /////////////////////////// 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /constructor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class nishkarsh 4 | { 5 | int sapid; 6 | string roll; 7 | public: 8 | nishkarsh(int sap,string rollnum) 9 | { 10 | sapid=sap; 11 | roll=rollnum; 12 | } 13 | void show() 14 | { 15 | cout<<"Sapid is "< 2 | using namespace std; 3 | class nishkarsh 4 | { 5 | int sapid; 6 | public: 7 | nishkarsh() 8 | { 9 | sapid=500060720; 10 | } 11 | nishkarsh(nishkarsh &x) 12 | { 13 | sapid=x.sapid; 14 | } 15 | void show() 16 | { 17 | cout< 2 | using namespace std; 3 | class nishkarsh 4 | { 5 | int sapid; 6 | public: 7 | nishkarsh() 8 | { 9 | sapid=500060720; 10 | } 11 | nishkarsh(nishkarsh &x) 12 | { 13 | sapid=x.sapid; 14 | } 15 | void show() 16 | { 17 | cout< 2 | using namespace std; 3 | float simple_interest(float p,int t,int rate=5); 4 | float simple_interest(float p,int t,int rate) 5 | { 6 | float SI; 7 | SI=(p*rate*t)/100; 8 | return SI; 9 | } 10 | int main() 11 | { 12 | float principal; int time; 13 | cout<<"Default Arguments program"<>principal>>time; 16 | float Simple=simple_interest(principal,time); 17 | cout<<"Simple interest is "< 2 | using namespace std; 3 | class nishkarsh 4 | { 5 | public: 6 | nishkarsh() 7 | { 8 | cout<<"I am constructor"< 2 | using namespace std; 3 | int main() 4 | { 5 | int *p; 6 | p=new int; 7 | *p=100; 8 | cout<<"Value to which p points is "<<*p; 9 | cout< 2 | using namespace std; 3 | class ABC 4 | { 5 | int a,b; 6 | public: 7 | <<<<<<< HEAD 8 | void setdata(int m,int n) 9 | { 10 | a=m,b=n; 11 | ======= 12 | void setdata() 13 | { 14 | a=10,b=25; 15 | >>>>>>> 068b4e7f2e1cef66939b6df29e22918251c1370b 16 | } 17 | friend float mean(class ABC x); 18 | }; 19 | float mean(ABC x) 20 | { 21 | cout<<(x.a+x.b)/2; 22 | } 23 | int main() 24 | { 25 | <<<<<<< HEAD 26 | int m,n; 27 | ABC y; 28 | cout<<"Enter two values whose mean you want"<>m>>n; 30 | y.setdata(m,n); 31 | mean(y); 32 | cout<>>>>>> 068b4e7f2e1cef66939b6df29e22918251c1370b 38 | } 39 | -------------------------------------------------------------------------------- /friendtwo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class endsem; //forward declaration for friendship 4 | class midsem 5 | { 6 | float Chemistry,Maths,EVS,PDS,DevOps,BEE; 7 | public: 8 | midsem() 9 | { 10 | Chemistry=93; 11 | Maths=81; 12 | EVS=74; 13 | PDS=78; 14 | DevOps=67; 15 | BEE=76; 16 | } 17 | friend void result(midsem,endsem); 18 | }; 19 | class endsem 20 | { 21 | float Chemistry,Maths,EVS,PDS,DevOps,BEE; 22 | public: 23 | endsem() 24 | { 25 | Chemistry=91; 26 | Maths=82; 27 | EVS=79; 28 | PDS=77; 29 | DevOps=91; 30 | BEE=77; 31 | } 32 | friend void result(midsem,endsem); 33 | }; 34 | void result(midsem M,endsem E) 35 | { 36 | float Chem=(M.Chemistry)/5+(E.Chemistry)/2; 37 | float Math=(M.Maths)/5+(E.Maths)/2; 38 | float Basic=(M.BEE)/5+(E.BEE)/2; 39 | float Env=(M.EVS)/5+(E.EVS)/2; 40 | float CS=(M.PDS)/5+(E.PDS)/2; 41 | float DO=(M.DevOps)/5+(E.DevOps)/2; 42 | cout<<"Final marks in Chemistry are "< 2 | using namespace std; 3 | void show(int a); 4 | void show(char b); 5 | //void show(float c); 6 | void show(int a) 7 | { 8 | cout<<"Hey! This is for int"< 2 | using namespace std; 3 | template 4 | void multiply(x x1,y y1) 5 | { 6 | float m; 7 | m=x1*y1; 8 | cout<<"Multiplied value is "<>x>>y; 15 | multiply(x,y); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /graph1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | class student 5 | { 6 | public: 7 | string rollnumber; 8 | string sapid; 9 | string name; 10 | string specialization; 11 | student *connections[10]; 12 | student() 13 | { 14 | rollnumber="R171217041"; 15 | sapid="500060720"; 16 | name="Nishkarsh"; 17 | specialization="DevOps"; 18 | } 19 | void insert() 20 | { 21 | cout<<"Enter the Registered Roll number of the Student"<>rollnumber; 23 | cout<<"Enter the SAP ID of the student"<>sapid; 25 | cout<<"Enter the Name(First only) of the Student"<>name; 27 | cout<<"Enter the Specialization of the Student"<>specialization; 29 | } 30 | void show() 31 | { 32 | cout<<"Roll Number of the student is "<>n; 52 | int A[10][10]; //Adjancy Matrix 53 | ////////////////////////////////////////////////////////////////////////Insertion 54 | if(n<=10) 55 | { 56 | student *stu[n]; 57 | for(i=0;iinsert(); 62 | for(j=0;j<10;j++) 63 | stu[i]->connections[j]=NULL; 64 | } 65 | //////////////////////////////////////////////////////////////////////Loading 66 | system("clear"); 67 | for(i=0;i<50000;i++) 68 | { 69 | cout<<"Please Wait!!! Loading Boot files of the program into the Active Memory case number "<=10000)&&(i<40000)) 75 | { 76 | cout<<"Processing the files and Optimising Disk Space"<name<<" and "<name<<"?\nIf yes please enter Y"<>rep; 102 | if((rep=='y')||(rep=='Y')) 103 | { 104 | A[i][j]=1; 105 | A[j][i]=1; 106 | } 107 | else 108 | { 109 | A[i][j]=0; 110 | } 111 | } 112 | else 113 | { 114 | continue; 115 | } 116 | }//end of for this 117 | } 118 | /////////////////////////////////////////////////////////////creation of adjancy list 119 | stud *node1[10],*p11,*ptr11; 120 | for(i=0;iname=stu[i]->name; 124 | node1[i]->next=NULL; 125 | for(j=0;jname=stu[j]->name; 131 | p11->next=NULL; 132 | node1[i]->next=p11; 133 | } 134 | } 135 | } 136 | /////////////////////////////////////////////////////////////creation of connections using adjancy matrix 137 | int k=0; 138 | for(i=0;iconnections[k++]=stu[j]; 144 | } 145 | k=0; 146 | } 147 | /////////////////////////////////////////////////////////////Option Menu 148 | int ch,quit=0; 149 | char rep11; 150 | system("clear"); 151 | do 152 | { 153 | cout<<"Option Menu"<>ch; 163 | switch(ch) 164 | { 165 | case 1: 166 | /////////////////////////////////////////////////////////////Insertion 167 | if(n<=10) 168 | { 169 | cout<<"Creation of new vertex"<insert(); 173 | for(i=0;i<10;i++) 174 | { 175 | stu[n]->connections[i]=NULL; 176 | } 177 | //Adjancy Matrix correction 178 | cout<<"Lets make the adjancy matrix now"<name<<" and "<name<<"?\nIf yes, press Y"<>rep11; 183 | if((rep11=='y')||(rep11=='Y')) 184 | { 185 | A[n][i]=1; 186 | A[i][n]=1; 187 | } 188 | else 189 | { 190 | A[n][i]=0; 191 | } 192 | } 193 | //Adjancy List correction 194 | //connections corrections 195 | } 196 | else 197 | { 198 | cout<<"The maximum limit has been reached! I am extremely sorry but no further insertions now."<name<name<<" is "<next) 224 | { 225 | cout<name<<"\t"; 226 | } 227 | cout<show(); 239 | } 240 | break; 241 | case 7: quit=1; 242 | break; 243 | default: cout<<"Why are we still here! Only to suffer! Please write a numerical integer value between 1 and 7 you stupid idiot"<>rep11; 248 | if((rep11=='y')||(rep11=='Y')) 249 | system("clear"); 250 | }while(quit!=1); 251 | /////////////////////////////////////////////////////////////Code above this only 252 | } 253 | else 254 | { 255 | cout<<"I told you to keep it withing 10! Now Goodbye! You don't deserve me"< 2 | using namespace std; 3 | class grandmother 4 | { 5 | protected: 6 | string name="Maya Rani Khare"; 7 | public: 8 | void show12() 9 | { 10 | cout<<"Name of the grandmother is "< 2 | using namespace std; 3 | class A 4 | { 5 | int a[10]; 6 | }; 7 | class B1: virtual public A 8 | { 9 | }; 10 | class B2: virtual public A 11 | { 12 | }; 13 | class B3: virtual public A 14 | { 15 | }; 16 | class derived: public B1, public B2, public B3 17 | { 18 | }; 19 | int main() 20 | { 21 | derived r; 22 | cout<<"Size of A is "< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ofstream nish("Independence.txt"); 7 | nish<<"Nishkarsh Raj Khare is the best baaybaaay!!!"<>s; 12 | cout<<"File had "< 2 | using namespace std; 3 | class A 4 | { 5 | int a[10]; int c=2; 6 | }; 7 | class B: private A 8 | { 9 | int b[10],x=2; 10 | public: 11 | void dis() 12 | { 13 | cout< 2 | using namespace std; 3 | class Nish 4 | { 5 | int sapid=500060720; 6 | string roll="R171217041"; 7 | public: 8 | void show() 9 | { 10 | cout<<"The sapid is "< 2 | using namespace std; 3 | void show1(); 4 | inline void show2(); 5 | void show1() 6 | { 7 | cout<<"Not inline"< 2 | using namespace std; 3 | class student 4 | { 5 | public: 6 | string rollno; 7 | string sapid; 8 | string name; 9 | string specialization; //added to commit 2 to make a better platform 10 | student *next; 11 | student() 12 | { 13 | rollno="R171217041"; 14 | sapid="500060720"; 15 | name="Nishkarsh Raj Khare"; 16 | specialization="DevOps"; 17 | } 18 | void insert() 19 | { 20 | cout<<"Enter the name of the person"<>name; 22 | cout<<"Enter the sapid of the student"<>sapid; 24 | cout<<"Enter the rollno of the student"<>rollno; 26 | cout<<"Enter the Specialization of the student"<>specialization; 28 | } 29 | void show() 30 | { 31 | cout<<"Name of the student is :"<insert(); 45 | node->next=NULL; 46 | cout<<"Lets see the details of first node"<show(); 48 | start=node; 49 | string n,n2; 50 | int flag=0; 51 | //creation of menu on commit 3 52 | int quit=0,choice; 53 | do 54 | { 55 | cout<<"\t\t\t\tOption Menu\n\n"<>choice; 66 | switch(choice) 67 | { 68 | case 1: cout<<"Insertion at Beginning"<insert(); 71 | ptr->next=start; 72 | start=ptr; 73 | break; 74 | case 2: cout<<"Insertion at End"<insert(); 77 | node->next=NULL; 78 | for(ptr=start;ptr->next!=NULL;ptr=ptr->next); 79 | ptr->next=node; 80 | break; 81 | case 3: cout<<"Insertion at any point"<>n; 84 | for(ptr=start;ptr!=NULL;ptr=ptr->next) 85 | { 86 | if(ptr->name==n) 87 | break; 88 | } 89 | node=new student; 90 | node->insert(); 91 | node->next=ptr->next; 92 | ptr->next=node; 93 | break; 94 | case 4: cout<<"Deletion at beginning"<next; 97 | delete ptr; 98 | break; 99 | case 5: cout<<"Deletion at End"<next!=NULL) 101 | { 102 | for(ptr=start;ptr->next!=NULL;p=ptr,ptr=ptr->next); 103 | delete ptr; 104 | p->next=NULL; 105 | } 106 | else 107 | delete start; 108 | break; 109 | case 6: cout<<"Deletion anywhere"<>n2; 112 | for(ptr=start;ptr->next!=NULL;p=ptr,ptr=ptr->next) 113 | { 114 | if(ptr->name==n2) 115 | { 116 | flag=1; 117 | break; 118 | } 119 | if(flag==1) 120 | { 121 | cout<<"Record Does not exist"<next=ptr->next; 126 | delete ptr; 127 | } 128 | } 129 | break; 130 | case 7: cout<<"Traversal"<next) 132 | ptr->show(); 133 | break; 134 | case 8: quit=1; 135 | break; 136 | default: cout<<"Wrong Choice! Please Try Again"< 2 | using namespace std; 3 | class student 4 | { 5 | protected: 6 | int rn; 7 | public: 8 | void getn(int a) 9 | { 10 | rn=a; 11 | } 12 | void putn() 13 | { 14 | cout<<"Roll number is "< 2 | using namespace std; 3 | class A 4 | { 5 | public: 6 | void show(){cout<<"A"< 2 | using namespace std; 3 | <<<<<<< HEAD 4 | class time1 5 | ======= 6 | class time 7 | >>>>>>> 068b4e7f2e1cef66939b6df29e22918251c1370b 8 | { 9 | int hours,minutes,seconds; 10 | public: 11 | void gettime() 12 | { 13 | cout<<"Enter hours,minutes and seconds respectively"<>hours>>minutes>>seconds; 15 | <<<<<<< HEAD 16 | cout<=60) 29 | { 30 | minutes=minutes+(seconds/60); 31 | seconds=seconds%60; 32 | } 33 | hours=t1.hours+t2.hours; 34 | if(minutes>=60) 35 | { 36 | hours=hours+(minutes/60); 37 | minutes=minutes%60; 38 | } 39 | } 40 | int main() 41 | { 42 | time1 t1; 43 | t1.gettime(); 44 | t1.showtime(); 45 | time1 t2; 46 | t2.gettime(); 47 | t2.showtime(); 48 | time1 t3; 49 | ======= 50 | } 51 | void showtime() 52 | { 53 | cout<<"hours is "<>>>>>> 068b4e7f2e1cef66939b6df29e22918251c1370b 74 | t3.sum(t1,t2); 75 | t3.showtime(); 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /pub_pri_call.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Nish 4 | { 5 | int sapid=500060720; 6 | string roll="R171217041"; 7 | string name="Nishkarsh Raj Khare"; 8 | void show() 9 | { 10 | cout<<"The sapid is "< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | ifstream nish("file_write_basic.txt"); 7 | string name,city; 8 | int pin; 9 | nish>>name>>city>>pin; 10 | cout<<"Lets see what our file had by using a program"< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | cout<<"Lets write and read from a file in one go maen!!!!!"<>name>>city>>roll; 12 | nish<>n>>c>>r; 21 | cout<<"Name is "< 2 | using namespace std; 3 | int main() 4 | { 5 | cout<<"Hello World"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /single_private.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: private base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | //cout<<"Protected Member of base "< 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: protected base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | cout<<"Protected Member of base "< 2 | using namespace std; 3 | class base 4 | { 5 | int a; 6 | protected: 7 | int b; 8 | public: 9 | int c; 10 | void set_data(int a1,int b1, int c1) 11 | { 12 | a=a1; b=b1; c=c1; 13 | } 14 | base() 15 | { 16 | a=10; b=15; c=20; 17 | } 18 | }; 19 | class derived: public base 20 | { 21 | int a2; 22 | protected: 23 | int b2; 24 | public: 25 | int c2; 26 | derived() 27 | { 28 | a2=5; 29 | b2=6; 30 | c2=10; 31 | } 32 | void show() 33 | { 34 | cout<<"Protected Member of base "< 2 | using namespace std; 3 | class sample 4 | { 5 | int samp; 6 | 7 | public://why?? 8 | static int sam; 9 | void read() 10 | { 11 | cout<<"Enter the values"<>samp>>sam; 13 | } 14 | void sample1() 15 | { 16 | cout<<"Non Static"< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | cout<<"Taking an entire string from the text file"<>s1; 15 | cout<<"Simple string intake "< 2 | #include //both the streams are needed 3 | using namespace std; 4 | int main() 5 | { 6 | ofstream nish("file_write_basic.txt"); //opening with help of constructor 7 | cout<<"Program to enter simple texts into the file"<>pincode; 15 | nish<