Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Day0-HelloWorld/C++/main_kunal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>

using namespace std;

int main() {
string input_string;
getline(cin, input_string);
cout << "Hello, World." << endl;
cout << input_string;
return 0;
}
50 changes: 50 additions & 0 deletions Day4-ClassVsInheritance/Cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using namespace std;
#include <iostream>

class Person{
public:
int age;
Person(int initialAge);
void amIOld();
void yearPasses();
};

Person::Person(int initialAge){
this->age = initialAge;
if(initialAge<0)
cout << "Age is not valid, setting age to 0."<<endl;
}

void Person::amIOld(){
if(age<13)
cout << "You are young."<<endl;
else if(age>=13 && age <18)
cout << "You are a teenager."<<endl;
else
cout<<"You are old."<<endl;
}

void Person::yearPasses(){

age=age+1;

}

int main(){
int t;
int age;
cin >> t;
for(int i=0; i < t; i++) {
cin >> age;
Person p(age);
p.amIOld();
for(int j=0; j < 3; j++) {
p.yearPasses();
}
p.amIOld();

cout << '\n';
}

return 0;
}
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-midnight