Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
01eb37f
Create C++ Else If.txt
TanayShukla May 4, 2021
1e0c233
Create C++_Short_Hand_If_Else.txt
TanayShukla May 6, 2021
ca0ee56
Create C++_Switch.txt
TanayShukla May 6, 2021
1fc72db
Create C++_While_Loop.txt
TanayShukla May 8, 2021
2018f44
Create C++Do_While_Loop.txt
TanayShukla May 9, 2021
0ed1618
Create C++_For_Loop.txt
TanayShukla May 9, 2021
0d5e459
Create C++_Break_and_Continue.txt
TanayShukla May 11, 2021
99aa0e5
Create C++ Arrays
TanayShukla May 12, 2021
41170f0
Create C++_References.txt
TanayShukla May 13, 2021
d0a61e8
Create C++_Pointers.txt
TanayShukla May 14, 2021
d8ca5e4
Create C++_Functions.txt
TanayShukla May 15, 2021
0eeeee0
Create C++_Function_Parameters.txt
TanayShukla May 15, 2021
e948ae0
Update C++_Function_Parameters.txt
TanayShukla May 15, 2021
eddddbf
Create C++Function_Overloading.txt
TanayShukla May 16, 2021
fae2f1b
Create C++_OOP.txt
TanayShukla May 18, 2021
58835d5
Update and rename C++ Arrays to C++Arrays.txt
TanayShukla May 18, 2021
46d3384
Create C++_Classes_and_Objects.txt
TanayShukla May 18, 2021
0237d46
Create C++_Class_Methods.txt
TanayShukla May 19, 2021
0094028
Create C++_Constructors.txt
TanayShukla May 20, 2021
4f8d4e1
Create C++_Access_Specifiers.txt
TanayShukla May 21, 2021
ef3cc60
Create C++_Encapsulation.txt
TanayShukla May 22, 2021
70d43a1
Create C++_Inheritance.txt
TanayShukla May 23, 2021
9d0944a
Create C++_Polymorphism.txt
TanayShukla May 25, 2021
300e531
Create C++_Files.txt
TanayShukla May 26, 2021
51a33fb
Create C++_Exceptions.txt
TanayShukla May 26, 2021
184b43c
Update C++ Booleans
TanayShukla May 27, 2021
623acaa
Update C++ Declare Multiple Variables.txt
TanayShukla May 27, 2021
4cd6811
Update C++ Else If.txt
TanayShukla May 27, 2021
2f174eb
Update C++ If ... Else.txt
TanayShukla May 27, 2021
eb07cff
Update C++ Output (Print Text)
TanayShukla May 27, 2021
0912df3
Update C++ Syntax.cpp
TanayShukla May 27, 2021
5df98a0
Update C++Arrays.txt
TanayShukla May 27, 2021
0fc21d3
Update C++Do_While_Loop.txt
TanayShukla May 27, 2021
01c0bfb
Update C++Logical_Operators,txt
TanayShukla May 27, 2021
2d429cf
Update C++_Access_Specifiers.txt
TanayShukla May 27, 2021
4f041f6
Update C++_Access_Strings.txt
TanayShukla May 27, 2021
e9cfab5
Update C++_Assignment Operators.txt
TanayShukla May 27, 2021
a241844
Create C++ How To Add Two Numbers
TanayShukla May 28, 2021
475e5df
Create C++_Examples.cpp
TanayShukla May 29, 2021
7c35f65
Create C++_Online Compiler.cpp
TanayShukla May 29, 2021
79d315f
Update C++_Online Compiler.cpp
TanayShukla May 29, 2021
e92043b
Create C++_Exercises.cpp
TanayShukla May 30, 2021
e9d8156
Update C++_While_Loop.txt
TanayShukla May 30, 2021
6f81a0c
Update C++_Files.txt
TanayShukla May 30, 2021
335d2a5
Create C++_Quiz.txt
TanayShukla Jun 1, 2021
b3ed4e0
Update readme.md
TanayShukla Jun 2, 2021
2651344
Update readme.md
TanayShukla Jun 3, 2021
ff398d3
Update C++ Else If.txt
TanayShukla Jun 3, 2021
ba20984
Update readme.md
TanayShukla Jun 4, 2021
5b903e5
Update README.md
TanayShukla Jun 5, 2021
5c181a8
Update README.md
TanayShukla Jun 5, 2021
0f58404
Update readme.md
TanayShukla Jun 6, 2021
8f72c20
Update readme.md
TanayShukla Jun 7, 2021
46788bd
Update readme.md
TanayShukla Jun 7, 2021
4c8d95e
Update readme.md
TanayShukla Jun 9, 2021
37ea256
Update readme.md
TanayShukla Jun 10, 2021
d140db6
Update readme.md
TanayShukla Jun 11, 2021
2e5112a
Update readme.md
TanayShukla Jun 12, 2021
3bcc1c9
Update readme.md
TanayShukla Jun 12, 2021
3879059
Update readme.md
TanayShukla Jun 13, 2021
5750427
Update readme.md
TanayShukla Jun 15, 2021
ac79498
Update README.md
TanayShukla Jun 16, 2021
bfd2dbf
Update README.md
TanayShukla Jun 17, 2021
b623528
Update README.md
TanayShukla Jun 18, 2021
88cc611
Update readme.md
TanayShukla Jun 19, 2021
b9d2e0e
Update readme.md
TanayShukla Jun 20, 2021
c9267ea
Update readme.md
TanayShukla Jun 21, 2021
8ddda20
Update README.md
TanayShukla Jun 22, 2021
d460b46
Update readme.md
TanayShukla Jun 22, 2021
9a53a91
Update readme.md
TanayShukla Jun 23, 2021
f56310e
Update README.md
TanayShukla Jun 26, 2021
3729d70
Update readme.md
TanayShukla Jun 26, 2021
f71c3d7
Update README.md
TanayShukla Jun 27, 2021
914d07a
Update readme.md
TanayShukla Jun 28, 2021
8862b5a
Update readme.md
TanayShukla Jun 29, 2021
3ea41da
Update readme.md
TanayShukla Jun 30, 2021
e80f46b
Update readme.md
TanayShukla Jul 3, 2021
1f205f4
Update readme.md
TanayShukla Jul 4, 2021
9fe4422
Update readme.md
TanayShukla Jul 6, 2021
e2d1163
Update readme.md
TanayShukla Jul 9, 2021
3aa58d8
Update readme.md
TanayShukla Jul 9, 2021
27072d6
Update readme.md
TanayShukla Jul 11, 2021
f848e9d
Update readme.md
TanayShukla Jul 12, 2021
ee9d1d8
Update readme.md
TanayShukla Jul 12, 2021
13e6868
Update readme.md
TanayShukla Jul 14, 2021
9a5dade
Update readme.md
TanayShukla Jul 16, 2021
b619ccd
Update readme.md
TanayShukla Jul 17, 2021
b3d528d
Update readme.md
TanayShukla Jul 20, 2021
fbe723c
Update readme.md
TanayShukla Jul 22, 2021
5694f04
Update readme.md
TanayShukla Jul 25, 2021
93406b1
Update readme.md
TanayShukla Jul 27, 2021
89889a6
Update readme.md
TanayShukla Jul 28, 2021
4d2dd24
Update readme.md
TanayShukla Jul 29, 2021
f214d2e
Update readme.md
TanayShukla Jul 30, 2021
23af628
Update readme.md
TanayShukla Jul 31, 2021
a12a325
Update readme.md
TanayShukla Aug 1, 2021
03606c9
Update readme.md
TanayShukla Aug 2, 2021
b1ad328
Update readme.md
TanayShukla Aug 3, 2021
a13cd1d
Update readme.md
TanayShukla Aug 3, 2021
c63151a
Update README.md
TanayShukla Aug 4, 2021
974964e
Update readme.md
TanayShukla Aug 4, 2021
6fe2be8
Update readme.md
TanayShukla Aug 6, 2021
fb7874c
Update readme.md
TanayShukla Aug 6, 2021
42d57c4
Update readme.md
TanayShukla Aug 8, 2021
405a4d5
Update readme.md
TanayShukla Aug 9, 2021
d4a5514
Update README.md
TanayShukla Aug 9, 2021
72b239a
Update readme.md
TanayShukla Aug 10, 2021
c624d9d
Update readme.md
TanayShukla Aug 12, 2021
739223a
Update readme.md
TanayShukla Aug 13, 2021
14a00d5
Update readme.md
TanayShukla Aug 15, 2021
5d22347
Update readme.md
TanayShukla Aug 15, 2021
3558bde
Update readme.md
TanayShukla Aug 17, 2021
91818f1
Update readme.md
TanayShukla Aug 19, 2021
341b2c1
Update readme.md
TanayShukla Aug 20, 2021
3d1a46a
Update readme.md
TanayShukla Aug 31, 2021
fa4368b
Update README.md
TanayShukla Oct 27, 2021
0ec2103
Update README.md
TanayShukla Oct 28, 2021
f7e0a6c
Update README.md
TanayShukla Nov 16, 2021
4633175
Update README.md
TanayShukla Jan 2, 2022
202b6ff
Update README.md
TanayShukla Jan 2, 2022
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Codeshow-100days_of_code
100DaysOfCode is a challenge/community, where you publicly commit to code for 1 hour for the next 100 days.

# Rules
-In our version, of 100DaysOfCode, you need to do anything that helps you enhance your tech stack i.e. competitive coding, try learning a new language, read technical articles/ books, make open source contributions, add features to a personal project, etc.

Expand All @@ -9,7 +8,6 @@
-Keep defining your short term goals (measurable) and strive hard to achieve them. (Eg. Getting better at competitive coding is not a measurable goal but achiving 2000 rating in Codechef is measurable.

-Update everyday progress and submit a pull request.

-(Optional) Follow 100DaysOfCode Twitter Bot that retweets the tweets that contain the #100DaysOfCode hashtag and timely tweet your progress with #100DaysOfCode hashtag.

-Try to add detailed description of what you did, add corresponding links, if you solve questions, you can add your codes in the same folder and provid a link in the README (not for active contests).
Expand Down Expand Up @@ -61,3 +59,4 @@ Basic git:
-Update the progress in your README according to date and submit a pull request.

-If you need more clarification, feel free to reach us at Whatsapp.

46 changes: 46 additions & 0 deletions Tanay/C++Function_Overloading.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
C++ Function Overloading
Function Overloading
With function overloading, multiple functions can have the same name with different parameters:

Example
int myFunction(int x)
float myFunction(float x)
double myFunction(double x, double y)
Consider the following example, which have two functions that add numbers of different type:

Example
int plusFuncInt(int x, int y) {
return x + y;
}

double plusFuncDouble(double x, double y) {
return x + y;
}

int main() {
int myNum1 = plusFuncInt(8, 5);
double myNum2 = plusFuncDouble(4.3, 6.26);
cout << "Int: " << myNum1 << "\n";
cout << "Double: " << myNum2;
return 0;
}
Instead of defining two functions that should do the same thing, it is better to overload one.

In the example below, we overload the plusFunc function to work for both int and double:

Example
int plusFunc(int x, int y) {
return x + y;
}

double plusFunc(double x, double y) {
return x + y;
}

int main() {
int myNum1 = plusFunc(8, 5);
double myNum2 = plusFunc(4.3, 6.26);
cout << "Int: " << myNum1 << "\n";
cout << "Double: " << myNum2;
return 0;
}
1 change: 1 addition & 0 deletions Tanay/CPP/C++ Booleans
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Booleans
Very often, in programming, you will need a data type that can only have one of two values, like:

Expand Down
1 change: 1 addition & 0 deletions Tanay/CPP/C++ Declare Multiple Variables.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Declare Multiple Variables
Declare Many Variables
To declare more than one variable of the same type, use a comma-separated list:
Expand Down
27 changes: 27 additions & 0 deletions Tanay/CPP/C++ Else If.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

The else if Statement

Use the else if statement to specify a new condition if the first condition is false.

Syntax
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
Example
int time = 22;
if (time < 10) {
cout << "Good morning.";
} else if (time < 20) {
cout << "Good day.";
} else {
cout << "Good evening.";
}
// Outputs "Good evening."
Example explained
In the example above, time (22) is greater than 10, so the first condition is false. The next condition, in the else if statement, is also false, so we move on to the else condition since condition1 and condition2 is both false - and print to the screen "Good evening".

However, if the time was 14, our program would print "Good day."
19 changes: 19 additions & 0 deletions Tanay/CPP/C++ How To Add Two Numbers
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Learn how to add two numbers in C++:

Example
int x = 5;
int y = 6;
int sum = x + y;
cout << sum;
Add Two Numbers with User Input
In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:

Example
int x, y;
int sum;
cout << "Type a number: ";
cin >> x;
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;
1 change: 1 addition & 0 deletions Tanay/CPP/C++ If ... Else.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ If ... Else
C++ Conditions and If Statements
C++ supports the usual logical conditions from mathematics:
Expand Down
1 change: 1 addition & 0 deletions Tanay/CPP/C++ Output (Print Text)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Output (Print Text)
C++ Output (Print Text)
The cout object, together with the << operator, is used to output values/print text:
Expand Down
1 change: 1 addition & 0 deletions Tanay/CPP/C++ Syntax.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

### C++ Syntax
et's break up the following code to understand it better:

Expand Down
34 changes: 34 additions & 0 deletions Tanay/CPP/C++Arrays.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

C++ Arrays.
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

To declare an array, define the variable type, specify the name of the array followed by square brackets and specify the number of elements it should store:

string cars[4];
We have now declared a variable that holds an array of four strings. To insert values to it, we can use an array literal - place the values in a comma-separated list, inside curly braces:

string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
To create an array of three integers, you could write:

int myNum[3] = {10, 20, 30};
Access the Elements of an Array
You access an array element by referring to the index number.

This statement accesses the value of the first element in cars:

Example
string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
cout << cars[0];
// Outputs Volvo
Note: Array indexes start with 0: [0] is the first element. [1] is the second element, etc.

Change an Array Element
To change the value of a specific element, refer to the index number:

Example
cars[0] = "Opel";
Example
string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
cars[0] = "Opel";
cout << cars[0];
// Now outputs Opel instead of Volvo
20 changes: 20 additions & 0 deletions Tanay/CPP/C++Do_While_Loop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

C++ Do/While Loop
The Do/While Loop
The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

Syntax
do {
// code block to be executed
}
while (condition);
The example below uses a do/while loop. The loop will always be executed at least once, even if the condition is false, because the code block is executed before the condition is tested:

Example
int i = 0;
do {
cout << i << "\n";
i++;
}
while (i < 5);
Do not forget to increase the variable used in the condition, otherwise the loop will never end!
1 change: 1 addition & 0 deletions Tanay/CPP/C++Logical_Operators,txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Logical Operators
Logical Operators
Logical operators are used to determine the logic between variables or values:
Expand Down
49 changes: 49 additions & 0 deletions Tanay/CPP/C++_Access_Specifiers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

C++ Access Specifiers
Access Specifiers
By now, you are quite familiar with the public keyword that appears in all of our class examples:

Example
class MyClass { // The class
public: // Access specifier
// class members goes here
};
The public keyword is an access specifier. Access specifiers define how the members (attributes and methods) of a class can be accessed. In the example above, the members are public - which means that they can be accessed and modified from outside the code.

However, what if we want members to be private and hidden from the outside world?

In C++, there are three access specifiers:

public - members are accessible from outside the class
private - members cannot be accessed (or viewed) from outside the class
protected - members cannot be accessed from outside the class, however, they can be accessed in inherited classes. You will learn more about Inheritance later.
In the following example, we demonstrate the differences between public and private members:

Example
class MyClass {
public: // Public access specifier
int x; // Public attribute
private: // Private access specifier
int y; // Private attribute
};

int main() {
MyClass myObj;
myObj.x = 25; // Allowed (public)
myObj.y = 50; // Not allowed (private)
return 0;
}
If you try to access a private member, an error occurs:

error: y is private
Note: It is possible to access private members of a class using a public method inside the same class. See the next chapter (Encapsulation) on how to do this.

Tip: It is considered good practice to declare your class attributes as private (as often as you can). This will reduce the possibility of yourself (or others) to mess up the code. This is also the main ingredient of the Encapsulation concept, which you will learn more about in the next chapter.

Note: By default, all members of a class are private if you don't specify an access specifier:

Example
class MyClass {
int x; // Private attribute
int y; // Private attribute
};
1 change: 1 addition & 0 deletions Tanay/CPP/C++_Access_Strings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Access Strings
Access Strings
You can access the characters in a string by referring to its index number inside square brackets [].
Expand Down
1 change: 1 addition & 0 deletions Tanay/CPP/C++_Assignment Operators.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

C++ Assignment Operators
Assignment Operators
Assignment operators are used to assign values to variables.
Expand Down
50 changes: 50 additions & 0 deletions Tanay/CPP/C++_Break_and_Continue.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
C++ Break and Continue
C++ Break
You have already seen the break statement used in an earlier chapter of this tutorial. It was used to "jump out" of a switch statement.

The break statement can also be used to jump out of a loop.

This example jumps out of the loop when i is equal to 4:

Example
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
cout << i << "\n";
}
C++ Continue
The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

This example skips the value of 4:

Example
for (int i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
cout << i << "\n";
}

Break and Continue in While Loop
You can also use break and continue in while loops:

Break Example
int i = 0;
while (i < 10) {
cout << i << "\n";
i++;
if (i == 4) {
break;
}
}
Continue Example
int i = 0;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
cout << i << "\n";
i++;
}
63 changes: 63 additions & 0 deletions Tanay/CPP/C++_Class_Methods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Class Methods
Methods are functions that belongs to the class.

There are two ways to define functions that belongs to a class:

Inside class definition
Outside class definition
In the following example, we define a function inside the class, and we name it "myMethod".

Note: You access methods just like you access attributes; by creating an object of the class and using the dot syntax (.):

Inside Example
class MyClass { // The class
public: // Access specifier
void myMethod() { // Method/function defined inside the class
cout << "Hello World!";
}
};

int main() {
MyClass myObj; // Create an object of MyClass
myObj.myMethod(); // Call the method
return 0;
}
To define a function outside the class definition, you have to declare it inside the class and then define it outside of the class. This is done by specifiying the name of the class, followed the scope resolution :: operator, followed by the name of the function:

Outside Example
class MyClass { // The class
public: // Access specifier
void myMethod(); // Method/function declaration
};

// Method/function definition outside the class
void MyClass::myMethod() {
cout << "Hello World!";
}

int main() {
MyClass myObj; // Create an object of MyClass
myObj.myMethod(); // Call the method
return 0;
}
Parameters
You can also add parameters:

Example
#include <iostream>
using namespace std;

class Car {
public:
int speed(int maxSpeed);
};

int Car::speed(int maxSpeed) {
return maxSpeed;
}

int main() {
Car myObj; // Create an object of Car
cout << myObj.speed(200); // Call the method with an argument
return 0;
}
Loading