From 5f7ebd89b52bbc900818a48e7a78491594c6679f Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 16:21:35 +0530 Subject: [PATCH 01/11] Added factorial using recursion file --- CPP/Factorial of number using recursion.cpp | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp new file mode 100644 index 0000000..ab118ef --- /dev/null +++ b/CPP/Factorial of number using recursion.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int factorial(int n); + +int main() +{ + int n; + + cout << "Enter a positive integer: "; + cin >> n; + + cout << "Factorial of " << n << " = " << factorial(n); + + return 0; +} + +int factorial(int n) +{ + if (n > 1) + return n * factorial(n - 1); + else + return 1; +} \ No newline at end of file From 7ecee7da640ae2115e1bc0fc3a4f8cd6bca6a741 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 17:29:18 +0530 Subject: [PATCH 02/11] Added new file --- ... => Find ASCII Value of a Character C.cpp} | 0 CPP/Roots of quadratic equation.cpp | 39 +++++++++++++++++++ ... order => sorting in dictionary order.cpp} | 0 3 files changed, 39 insertions(+) rename CPP/{Find ASCII Value of a Character C => Find ASCII Value of a Character C.cpp} (100%) create mode 100644 CPP/Roots of quadratic equation.cpp rename CPP/{sorting in dictionary order => sorting in dictionary order.cpp} (100%) diff --git a/CPP/Find ASCII Value of a Character C b/CPP/Find ASCII Value of a Character C.cpp similarity index 100% rename from CPP/Find ASCII Value of a Character C rename to CPP/Find ASCII Value of a Character C.cpp diff --git a/CPP/Roots of quadratic equation.cpp b/CPP/Roots of quadratic equation.cpp new file mode 100644 index 0000000..232c14c --- /dev/null +++ b/CPP/Roots of quadratic equation.cpp @@ -0,0 +1,39 @@ +#include +#include +using namespace std; + +int main() +{ + + float a, b, c, x1, x2, discriminant, realPart, imaginaryPart; + cout << "Enter coefficients a, b and c: "; + cin >> a >> b >> c; + discriminant = b * b - 4 * a * c; + + if (discriminant > 0) + { + x1 = (-b + sqrt(discriminant)) / (2 * a); + x2 = (-b - sqrt(discriminant)) / (2 * a); + cout << "Roots are real and different." << endl; + cout << "x1 = " << x1 << endl; + cout << "x2 = " << x2 << endl; + } + + else if (discriminant == 0) + { + cout << "Roots are real and same." << endl; + x1 = (-b + sqrt(discriminant)) / (2 * a); + cout << "x1 = x2 =" << x1 << endl; + } + + else + { + realPart = -b / (2 * a); + imaginaryPart = sqrt(-discriminant) / (2 * a); + cout << "Roots are complex and different." << endl; + cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl; + cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl; + } + + return 0; +} \ No newline at end of file diff --git a/CPP/sorting in dictionary order b/CPP/sorting in dictionary order.cpp similarity index 100% rename from CPP/sorting in dictionary order rename to CPP/sorting in dictionary order.cpp From 8905883b3ed4e9704e9e9af0eb2b989fafb1e838 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 17:48:48 +0530 Subject: [PATCH 03/11] Added program to generate Multiplication table using C++ --- CPP/Multiplication table.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 CPP/Multiplication table.cpp diff --git a/CPP/Multiplication table.cpp b/CPP/Multiplication table.cpp new file mode 100644 index 0000000..295534d --- /dev/null +++ b/CPP/Multiplication table.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int main() +{ + int n; + + cout << "Enter a positive integer: "; + cin >> n; + + for (int i = 1; i <= 10; ++i) + { + cout << n << " * " << i << " = " << n * i << endl; + } + + return 0; +} \ No newline at end of file From 52d954a23f665d279ce12a0f6f2adfd130575342 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:18:28 +0530 Subject: [PATCH 04/11] Revert "Added factorial using recursion file" This reverts commit 5f7ebd89b52bbc900818a48e7a78491594c6679f. --- CPP/Factorial of number using recursion.cpp | 24 --------------------- 1 file changed, 24 deletions(-) delete mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp deleted file mode 100644 index ab118ef..0000000 --- a/CPP/Factorial of number using recursion.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -using namespace std; - -int factorial(int n); - -int main() -{ - int n; - - cout << "Enter a positive integer: "; - cin >> n; - - cout << "Factorial of " << n << " = " << factorial(n); - - return 0; -} - -int factorial(int n) -{ - if (n > 1) - return n * factorial(n - 1); - else - return 1; -} \ No newline at end of file From b3692c310691c3d5f651f9bca0360e9041019b00 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:24:47 +0530 Subject: [PATCH 05/11] Revert "Added program to generate Multiplication table using C++" This reverts commit 8905883b3ed4e9704e9e9af0eb2b989fafb1e838. --- CPP/Multiplication table.cpp | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 CPP/Multiplication table.cpp diff --git a/CPP/Multiplication table.cpp b/CPP/Multiplication table.cpp deleted file mode 100644 index 295534d..0000000 --- a/CPP/Multiplication table.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -using namespace std; - -int main() -{ - int n; - - cout << "Enter a positive integer: "; - cin >> n; - - for (int i = 1; i <= 10; ++i) - { - cout << n << " * " << i << " = " << n * i << endl; - } - - return 0; -} \ No newline at end of file From 3f51a04d9ab3b5fdf10613b41d69768177d24ba0 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:26:20 +0530 Subject: [PATCH 06/11] Revert "Added new file" This reverts commit 7ecee7da640ae2115e1bc0fc3a4f8cd6bca6a741. --- ....cpp => Find ASCII Value of a Character C} | 0 CPP/Roots of quadratic equation.cpp | 39 ------------------- ... order.cpp => sorting in dictionary order} | 0 3 files changed, 39 deletions(-) rename CPP/{Find ASCII Value of a Character C.cpp => Find ASCII Value of a Character C} (100%) delete mode 100644 CPP/Roots of quadratic equation.cpp rename CPP/{sorting in dictionary order.cpp => sorting in dictionary order} (100%) diff --git a/CPP/Find ASCII Value of a Character C.cpp b/CPP/Find ASCII Value of a Character C similarity index 100% rename from CPP/Find ASCII Value of a Character C.cpp rename to CPP/Find ASCII Value of a Character C diff --git a/CPP/Roots of quadratic equation.cpp b/CPP/Roots of quadratic equation.cpp deleted file mode 100644 index 232c14c..0000000 --- a/CPP/Roots of quadratic equation.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -using namespace std; - -int main() -{ - - float a, b, c, x1, x2, discriminant, realPart, imaginaryPart; - cout << "Enter coefficients a, b and c: "; - cin >> a >> b >> c; - discriminant = b * b - 4 * a * c; - - if (discriminant > 0) - { - x1 = (-b + sqrt(discriminant)) / (2 * a); - x2 = (-b - sqrt(discriminant)) / (2 * a); - cout << "Roots are real and different." << endl; - cout << "x1 = " << x1 << endl; - cout << "x2 = " << x2 << endl; - } - - else if (discriminant == 0) - { - cout << "Roots are real and same." << endl; - x1 = (-b + sqrt(discriminant)) / (2 * a); - cout << "x1 = x2 =" << x1 << endl; - } - - else - { - realPart = -b / (2 * a); - imaginaryPart = sqrt(-discriminant) / (2 * a); - cout << "Roots are complex and different." << endl; - cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl; - cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl; - } - - return 0; -} \ No newline at end of file diff --git a/CPP/sorting in dictionary order.cpp b/CPP/sorting in dictionary order similarity index 100% rename from CPP/sorting in dictionary order.cpp rename to CPP/sorting in dictionary order From 4be9aaddfa0dceb2f6386fe46cf1e44adf9163c1 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:30:18 +0530 Subject: [PATCH 07/11] Factorial of number using recursion added --- CPP/Factorial of number using recursion.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp new file mode 100644 index 0000000..e69de29 From 76a33ff1b934fdc9256364c4d679341eb767d1b4 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:32:05 +0530 Subject: [PATCH 08/11] Revert "Factorial of number using recursion added" This reverts commit 4be9aaddfa0dceb2f6386fe46cf1e44adf9163c1. --- CPP/Factorial of number using recursion.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp deleted file mode 100644 index e69de29..0000000 From dd366fc1c77ea220679cfd40845941e724b15c4f Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:36:10 +0530 Subject: [PATCH 09/11] Factorial of number using recursion is added --- CPP/Factorial of number using recursion.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp new file mode 100644 index 0000000..e69de29 From eb75a133517976fe3ab90458e94661744dcc3813 Mon Sep 17 00:00:00 2001 From: Aalok Shah <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:42:30 +0530 Subject: [PATCH 10/11] Delete Factorial of number using recursion.cpp --- CPP/Factorial of number using recursion.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 CPP/Factorial of number using recursion.cpp diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp deleted file mode 100644 index e69de29..0000000 From f8db6bd15dfc28ff5c6542252a9a66d2445639d6 Mon Sep 17 00:00:00 2001 From: aalok28 <51107195+aalok28@users.noreply.github.com> Date: Mon, 19 Oct 2020 19:43:10 +0530 Subject: [PATCH 11/11] Factorial of number using recursion added --- CPP/Factorial of number using recursion.cpp | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CPP/Factorial of number using recursion.cpp b/CPP/Factorial of number using recursion.cpp index e69de29..ab118ef 100644 --- a/CPP/Factorial of number using recursion.cpp +++ b/CPP/Factorial of number using recursion.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int factorial(int n); + +int main() +{ + int n; + + cout << "Enter a positive integer: "; + cin >> n; + + cout << "Factorial of " << n << " = " << factorial(n); + + return 0; +} + +int factorial(int n) +{ + if (n > 1) + return n * factorial(n - 1); + else + return 1; +} \ No newline at end of file