commit 079243001073bd091af7dea1efa75a65c079c8a2
parent 06b1e3e11b7c6edaf64530633faa7bcfabdac5d1
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Mon, 22 Jun 2026 21:19:37 +0530
more practice
Diffstat:
14 files changed, 509 insertions(+), 3 deletions(-)
diff --git a/.vscode/README.md b/.vscode/README.md
@@ -0,0 +1,2 @@
+> **💡 Developer Note:**
+> To build and compile the active C file, press **`Ctrl` + `Shift` + `B`**. The repository is configured to handle Git pulls automatically when the workspace is opened.+
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
@@ -6,5 +6,6 @@
"strings": false
},
"editor.snippetSuggestions": "top"
- }
+ },
+ "r.lsp.promptToInstall": false
}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
@@ -1,6 +1,21 @@
{
+ "version": "2.0.0",
"tasks": [
{
+ "label": "Silent Auto-Pull",
+ "type": "shell",
+ "command": "git pull",
+ "runOptions": {
+ "runOn": "folderOpen"
+ },
+ "presentation": {
+ "reveal": "never",
+ "panel": "shared",
+ "showReuseMessage": false,
+ "clear": true
+ }
+ },
+ {
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
@@ -23,6 +38,5 @@
},
"detail": "Task generated by Debugger."
}
- ],
- "version": "2.0.0"
+ ]
}
\ No newline at end of file
diff --git a/semester_2/practice/prac_002.cpp b/semester_2/practice/prac_002.cpp
@@ -0,0 +1,40 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* design a class circle.take radius as input, calculate the area */
+
+#include <iostream>
+using namespace std;
+
+class circle {
+ int radius, area;
+
+public:
+ int input();
+ int calculation();
+ int output();
+};
+
+int circle::input() {
+ cout << "\nEnter the radius of the circle : ";
+ cin >> radius;
+}
+
+int circle::calculation() {
+ area = 3.14159 * radius * radius;
+}
+
+int circle::output() {
+ cout << "\nThe area of the circle is : " << area;
+}
+
+int main() {
+ circle z;
+ z.input();
+ z.calculation();
+ z.output();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_003.cpp b/semester_2/practice/prac_003.cpp
@@ -0,0 +1,42 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* Addition of two inputs */
+
+#include <iostream>
+using namespace std;
+
+class addoftwoinput {
+ int inp1, inp2, out;
+
+public:
+ void input();
+ void calculation();
+ void output();
+};
+
+void addoftwoinput ::input() {
+ cout << "\nInsert the 1st number : ";
+ cin >> inp1;
+ cout << "\nInsert the 2nd number : ";
+ cin >> inp2;
+}
+
+void addoftwoinput ::calculation() {
+ out = inp1 + inp2;
+}
+
+void addoftwoinput ::output() {
+ cout << "\nSum of " << inp1 << " and " << inp2 << " is : " << out;
+}
+
+int main() {
+ addoftwoinput z;
+ z.input();
+ z.calculation();
+ z.output();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_004.cpp b/semester_2/practice/prac_004.cpp
@@ -0,0 +1,41 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* check even or odd */
+
+#include <iostream>
+using namespace std;
+class ooe {
+ int n;
+
+public:
+ void input();
+ void calcdisp();
+};
+
+void ooe::input() {
+ cout << "Enter the number : ";
+ cin >> n;
+}
+
+void ooe::calcdisp() {
+ if (n == 0) {
+ cout << "0 neither a odd or a even number.";
+ }
+ else if (n % 2 == 0) {
+ cout << n << " is a even number.";
+ }
+ else {
+ cout << n << " is a odd number.";
+ }
+}
+
+int main() {
+ ooe a;
+ a.input();
+ a.calcdisp();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_005.cpp b/semester_2/practice/prac_005.cpp
@@ -0,0 +1,45 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* check prime or not */
+
+#include <iostream>
+using namespace std;
+
+class ponp {
+ int input, i;
+
+public:
+ void getinput();
+ void calcdisp();
+};
+
+void ponp::getinput() {
+ cout << "please enter the value : ";
+ cin >> input;
+}
+
+void ponp::calcdisp() {
+ if (input <= 1) {
+ cout << "This is not a prime number.";
+ return;
+ }
+
+ for (i = 2; i <= input / 2; i++) {
+ if (input % i == 0) {
+ cout << "this is not a prime number.";
+ return;
+ }
+ }
+ cout << "prime";
+}
+
+int main() {
+ ponp z;
+ z.getinput();
+ z.calcdisp();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_006.cpp b/semester_2/practice/prac_006.cpp
@@ -0,0 +1,43 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* factorial */
+
+#include <iostream>
+using namespace std;
+
+class fact {
+ int inp, a, i;
+
+public:
+ void input();
+ void calc();
+ void diplay();
+};
+
+void fact::input() {
+ cout << "enter the number :";
+ cin >> inp;
+ a = inp;
+}
+
+void fact::calc() {
+ for (i = 1; i <= inp - 1; i++) {
+ a = a * i;
+ }
+}
+
+void fact::diplay() {
+ cout << "Factorial " << a << ".";
+}
+
+int main() {
+ fact z;
+ z.input();
+ z.calc();
+ z.diplay();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_007.cpp b/semester_2/practice/prac_007.cpp
@@ -0,0 +1,42 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* sum of natural numbers upto n */
+
+#include <iostream>
+using namespace std;
+
+class add {
+ int inp, i, a = 0;
+
+public:
+ void input();
+ void calc();
+ void output();
+};
+
+void add::input() {
+ cout << "enter the number : ";
+ cin >> inp;
+}
+
+void add::calc() {
+ for (i = 1; i <= inp; i++) {
+ a = a + i;
+ }
+}
+
+void add::output() {
+ cout << "Addtion = " << a;
+}
+
+int main() {
+ add z;
+ z.input();
+ z.calc();
+ z.output();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_008.cpp b/semester_2/practice/prac_008.cpp
@@ -0,0 +1,40 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* number reverse */
+
+#include <iostream>
+using namespace std;
+
+class rev {
+ int inp, a = 0, b = 0;
+
+public:
+ void input();
+ void calc();
+};
+
+void rev::input() {
+ cout << "enter the number to reverse : ";
+ cin >> inp;
+ a = inp;
+}
+
+void rev::calc() {
+ while (inp != 0) {
+ a = inp % 10;
+ b = b * 10 + a;
+ inp = inp / 10;
+ }
+ cout << b;
+}
+
+int main() {
+ rev z;
+ z.input();
+ z.calc();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_009.cpp b/semester_2/practice/prac_009.cpp
@@ -0,0 +1,44 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* sum of digits */
+
+#include <iostream>
+using namespace std;
+
+class digitsum {
+ int inp, a = 0, b = 0;
+
+public:
+ void input();
+ void calc();
+ void output();
+};
+
+void digitsum::input() {
+ cout << "enter the number :";
+ cin >> inp;
+}
+
+void digitsum::calc() {
+ while (inp > 0) {
+ a = inp % 10;
+ b = b + a;
+ inp = inp / 10;
+ }
+}
+
+void digitsum::output() {
+ cout << "sum of the digits : " << b << ".";
+}
+
+int main() {
+ digitsum z;
+ z.input();
+ z.calc();
+ z.output();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_010.cpp b/semester_2/practice/prac_010.cpp
@@ -0,0 +1,42 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* check odd or even */
+
+#include <iostream>
+using namespace std;
+
+class ooe {
+ int n;
+
+public:
+ void input();
+ void calcdisp();
+};
+
+void ooe::input() {
+ cout << "Enter the number : ";
+ cin >> n;
+}
+
+void ooe::calcdisp() {
+ if (n == 0) {
+ cout << "0 is neither an odd nor an even number.";
+ }
+ else if (n % 2 == 0) {
+ cout << n << " is a even number.";
+ }
+ else {
+ cout << n << " is a odd number.";
+ }
+}
+
+int main() {
+ ooe a;
+ a.input();
+ a.calcdisp();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_011.cpp b/semester_2/practice/prac_011.cpp
@@ -0,0 +1,56 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* average of elements */
+
+#include <iostream>
+using namespace std;
+
+class avarage {
+ int inp[100], sum = 0, n, i;
+ float avg;
+
+public:
+ void input();
+ void calculation();
+ void output();
+};
+
+void avarage::input() {
+ cout << "\nEnter the number of elements : ";
+ cin >> n;
+ i = 0;
+ while (i < n) {
+ cout << "\nEnter the element no " << i + 1 << " : ";
+ cin >> inp[i];
+ i++;
+ }
+}
+
+void avarage::calculation() {
+ i = 0;
+ for (i = 0; i < n; i++) {
+ sum = sum + inp[i];
+ }
+ avg = (float)sum / n;
+}
+
+void avarage::output() {
+ i = 0;
+ cout << "\nAvarage of the element ";
+ for (i = 0; i < n; i++) {
+ cout << " " << inp[i];
+ }
+ cout << " is : " << avg;
+}
+
+int main() {
+ avarage z;
+ z.input();
+ z.calculation();
+ z.output();
+ return 0;
+}+
\ No newline at end of file
diff --git a/semester_2/practice/prac_012.cpp b/semester_2/practice/prac_012.cpp
@@ -0,0 +1,42 @@
+/*
+ * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
+ * Repo: https://github.com/notamitgamer/bsc
+ * License: MIT
+ */
+
+/* factorial using loop */
+
+#include <iostream>
+using namespace std;
+
+class fact {
+ int inp, a = 1, i;
+
+public:
+ void input();
+ void calc();
+ void output();
+};
+
+void fact::input() {
+ cout << "enter the number :";
+ cin >> inp;
+}
+
+void fact::calc() {
+ for (i = 1; i <= inp; i++) {
+ a = a * i;
+ }
+}
+
+void fact::output() {
+ cout << "factorial : " << a;
+}
+
+int main() {
+ fact z;
+ z.input();
+ z.calc();
+ z.output();
+ return 0;
+}+
\ No newline at end of file