commit c5739745e301f637f969542ff7a769bd345daf64
parent 2f6e9729b2252990d636420bd3339a6ea4c44819
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Wed, 10 Dec 2025 21:10:44 +0530
[2025-12-10] .\assignment-secondary\..\ : Added 8 assignment files for assignment-secondary folder.
Diffstat:
9 files changed, 752 insertions(+), 276 deletions(-)
diff --git a/assignment-secondary/assignment-s-01.c b/assignment-secondary/assignment-s-01.c
@@ -0,0 +1,39 @@
+/* Write a program to compute the sum and product of digits of an integer using user
+defined functions. */
+
+#include <stdio.h>
+
+int sum_of_digits(int);
+int product_of_digits(int);
+
+int main()
+{
+ int num;
+ printf("Enter the number: ");
+ scanf("%d", &num);
+ printf("\nSum of digits of %d = %d", num, sum_of_digits(num));
+ printf("\nProduct of digits of %d = %d", num, product_of_digits(num));
+ return 0;
+}
+
+int sum_of_digits(int num)
+{
+ int sum = 0;
+ while (num > 0)
+ {
+ sum += num % 10;
+ num /= 10;
+ }
+ return sum;
+}
+
+int product_of_digits(int num)
+{
+ int product = 1;
+ while (num > 0)
+ {
+ product *= num % 10;
+ num /= 10;
+ }
+ return product;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-02.c b/assignment-secondary/assignment-s-02.c
@@ -0,0 +1,30 @@
+/* Write a program to reverse a non-negative integer using a function. */
+
+#include <stdio.h>
+
+int reverse(int);
+
+int main()
+{
+ int num;
+ printf("Enter a non-negetive integer: ");
+ scanf("%d", &num);
+ if (num < 0)
+ {
+ printf("\nOnly non-negetive integers are allowed.");
+ return 1;
+ }
+ printf("\nReverse of the integer %d = %d", num, reverse(num));
+ return 0;
+}
+
+int reverse(int num)
+{
+ int rev = 0;
+ while (num > 0)
+ {
+ rev = (rev * 10) + (num % 10);
+ num /= 10;
+ }
+ return rev;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-03.c b/assignment-secondary/assignment-s-03.c
@@ -0,0 +1,33 @@
+/* Write a program to compute the sum of the first n terms of the series using a function:
+S=1−2+3−4+5−6+… */
+
+#include <stdio.h>
+
+int sum_of_series(int);
+
+int main()
+{
+ int n;
+ printf("Enter the n: ");
+ scanf("%d", &n);
+ printf("\nSum of the first %d terms of the series = %d", n, sum_of_series(n));
+ return 0;
+}
+
+int sum_of_series(int n)
+{
+ int sum = 0;
+ int i;
+ for (i = 1; i <= n; i++)
+ {
+ if (i % 2 == 0)
+ {
+ sum -= i;
+ }
+ else
+ {
+ sum += i;
+ }
+ }
+ return sum;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-04.c b/assignment-secondary/assignment-s-04.c
@@ -0,0 +1,52 @@
+/* Write a function to check whether a number is prime or not. Use the same function to
+generate all prime numbers less than 100. */
+
+#include <stdio.h>
+#include <math.h>
+
+int isPrime(int);
+
+int main()
+{
+ int n, i;
+ printf("Enter the number: ");
+ scanf("%d", &n);
+ if (isPrime(n))
+ {
+ printf("\nInput %d is a Prime Number.", n);
+ }
+ else
+ {
+ printf("\nInput %d is not a Prime Number.", n);
+ }
+ printf("\nPrime Numbers less than 100:");
+ for (i = 1; i < 100; i++)
+ {
+ if (isPrime(i))
+ {
+ printf(" %d", i);
+ }
+ }
+ return 0;
+}
+
+int isPrime(int n)
+{
+ if (n <= 1)
+ return 0;
+ if (n == 2)
+ return 1;
+ if (n % 2 == 0)
+ return 0;
+
+ int temp = (int)sqrt(n);
+ int i;
+ for (i = 3; i <= temp; i += 2)
+ {
+ if (n % i == 0)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-05.c b/assignment-secondary/assignment-s-05.c
@@ -0,0 +1,59 @@
+/* Write a function to check whether a given string is a palindrome. Use this function to
+determine whether an entered string is Palindrome. */
+
+#include <stdio.h>
+#include <string.h>
+
+int isPalindrome(char[]);
+
+int main()
+{
+ char input[100];
+ int len;
+
+ printf("Enter the string (Max: 100 Character): ");
+ fgets(input, sizeof(input), stdin);
+ len = strlen(input);
+
+ if (len > 0 && input[len - 1] == '\n')
+ {
+ input[len - 1] = '\0';
+ }
+
+ if (isPalindrome(input))
+ {
+ printf("\nInput string \"%s\" is Palindrome.", input);
+ }
+ else
+ {
+ printf("\nInput string \"%s\" is not Palindrome", input);
+ }
+
+ return 0;
+}
+
+int isPalindrome(char str[])
+{
+ char *start = str;
+ char *end;
+ int len = strlen(str);
+
+ if (len == 0)
+ {
+ return 1;
+ }
+
+ end = str + (len - 1);
+
+ while (start < end)
+ {
+ if (*start != *end)
+ {
+ return 0;
+ }
+ start++;
+ end--;
+ }
+
+ return 1;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-06.c b/assignment-secondary/assignment-s-06.c
@@ -0,0 +1,36 @@
+/* Write a program using a function to compute and display all factors of a given number. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void display_factors(int);
+
+int main()
+{
+ int num, i;
+ printf("Please enter the number to get the factors from it : ");
+ scanf("%d", &num);
+ display_factors(num);
+ return 0;
+}
+
+void display_factors(int num) {
+ int temp = abs(num);
+ int i;
+
+ if (temp == 0)
+ {
+ printf("\n0 has infinitely many factors (all integers).");
+ exit(1);
+ }
+
+ printf("\nThe factors of ' %d ' is :- ", num);
+ printf("\nPositive : ");
+ for (i = 1; i <= temp; i++)
+ if (temp % i == 0)
+ printf(" %d", i);
+ printf("\nNegative : ");
+ for (i = 1; i <= temp; i++)
+ if (temp % i == 0)
+ printf(" %d", -i);
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-07.c b/assignment-secondary/assignment-s-07.c
@@ -0,0 +1,40 @@
+/* Write a program to swap two numbers using a macro (#define). */
+
+// IMPOSSIBLE
+/* It is impossible to swap two literal numbers defined using the
+preprocessor directive #define. This is because #define performs simple
+text substitution and does not create variables in memory that can be
+manipulated or pointed to. */
+
+// Using a Function-Like Macro
+
+#include <stdio.h>
+
+// Define the SWAP macro.
+// The do-while(0) block is a common trick to ensure the macro behaves
+// like a single statement, regardless of where it is used (e.g., inside an 'if' statement).
+#define SWAP(a, b, data_type) \
+ do { \
+ data_type temp = a; \
+ a = b; \
+ b = temp; \
+ } while(0)
+
+int main() {
+ int num1 = 15;
+ int num2 = 42;
+
+ printf("--- Before Swap ---\n");
+ printf("Number 1 (num1): %d\n", num1);
+ printf("Number 2 (num2): %d\n", num2);
+
+ // Call the macro, passing the variables and their type
+ // The preprocessor replaces this line with the block of code defined above.
+ SWAP(num1, num2, int);
+
+ printf("\n--- After Swap (using macro) ---\n");
+ printf("Number 1 (num1): %d\n", num1);
+ printf("Number 2 (num2): %d\n", num2);
+
+ return 0;
+}+
\ No newline at end of file
diff --git a/assignment-secondary/assignment-s-08.c b/assignment-secondary/assignment-s-08.c
@@ -0,0 +1,39 @@
+/* Write a program that counts the number of occurrences of each alphabet (A-Z, a-z) in
+the text entered using Command-Line Arguments. */
+
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+ int target[2], i, j, count[2], len;
+ for (target[0] = 'A', target[1] = 'a'; target[0] <= 'Z', target[1] <= 'z'; target[0]++, target[1]++)
+ {
+ count[0] = 0;
+ count[1] = 0;
+ for (i = 1; i < argc; i++)
+ {
+ len = strlen(argv[i]);
+ for (j = 0; j < len; j++)
+ {
+ if (argv[i][j] == target[0])
+ {
+ count[0]++;
+ }
+ if (argv[i][j] == target[1])
+ {
+ count[1]++;
+ }
+ }
+ }
+ if (count[0])
+ {
+ printf("\n\"%c\" found %d times.", target[0], count[0]);
+ }
+ if (count[1])
+ {
+ printf("\n\"%c\" found %d times.", target[1], count[1]);
+ }
+ }
+ return 0;
+}+
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
@@ -208,36 +208,36 @@
<ul class="space-y-3">
<li class="border rounded-lg overflow-hidden">
- <div class="folder-header bg-gray-100 p-4 cursor-pointer hover:bg-blue-100 transition-colors duration-200" onclick="toggleFolder('assignment')">
+ <div class="folder-header bg-gray-100 p-4 cursor-pointer hover:bg-blue-100 transition-colors duration-200" onclick="toggleFolder('assignment-primary')">
<div class="flex items-center justify-between">
<div class="flex items-center">
<svg class="w-6 h-6 text-blue-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path></svg>
- <span class="font-medium text-gray-800">assignment</span>
+ <span class="font-medium text-gray-800">assignment-primary</span>
<span class="ml-2 text-sm text-gray-500">(15 files)</span>
</div>
<div class="flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/tree/main/assignment" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/tree/main/assignment-primary" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <div class="chevron" id="chevron-assignment"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div>
+ <div class="chevron" id="chevron-assignment-primary"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div>
</div>
</div>
</div>
- <div class="folder-content hidden bg-white" id="folder-assignment">
+ <div class="folder-content hidden bg-white" id="folder-assignment-primary">
<ul class="divide-y divide-gray-200">
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment01.c</span>
+ <span class="text-gray-700">assignment-p-01.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment01.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-01.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment01_c', 'assignment01.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-01_c', 'assignment-p-01.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment01_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment01.c">
+ <div id="code-assignment-primary-assignment-p-01_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-01.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named isPrime with the signature
int isPrime(int num); The function should take an integer as a parameter and return 1 if
the number is prime and 0 otherwise. */
@@ -292,15 +292,15 @@ int isPrime(int n)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment02.c</span>
+ <span class="text-gray-700">assignment-p-02.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment02.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-02.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment02_c', 'assignment02.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-02_c', 'assignment-p-02.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment02_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment02.c">
+ <div id="code-assignment-primary-assignment-p-02_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-02.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named isArmstrong with the
signature int isArmstrong(int num);. An Armstrong number is a number that is equal to
the sum of its own digits each raised to the power of the number of digits. For example,
@@ -367,15 +367,15 @@ int isArmstrong(int n)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment03.c</span>
+ <span class="text-gray-700">assignment-p-03.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment03.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-03.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment03_c', 'assignment03.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-03_c', 'assignment-p-03.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment03_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment03.c">
+ <div id="code-assignment-primary-assignment-p-03_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-03.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named isPerfect with the signature
int isPerfect(int num);. A perfect number is a positive integer that is equal to the sum of
its proper divisors, excluding itself. For example, 28 is a perfect number because the sum
@@ -423,15 +423,15 @@ int isPerfect(int n)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment04.c</span>
+ <span class="text-gray-700">assignment-p-04.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment04.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-04.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment04_c', 'assignment04.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-04_c', 'assignment-p-04.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment04_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment04.c">
+ <div id="code-assignment-primary-assignment-p-04_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-04.c">
<pre><code class="language-c">/* Write a C program that takes an integer input representing a month (1 to 12) and a year.
Use a switch statement to display the number of days in that month, considering leap years. */
@@ -485,15 +485,15 @@ int main()
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment05.c</span>
+ <span class="text-gray-700">assignment-p-05.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment05.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-05.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment05_c', 'assignment05.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-05_c', 'assignment-p-05.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment05_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment05.c">
+ <div id="code-assignment-primary-assignment-p-05_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-05.c">
<pre><code class="language-c">/* Write a C program that defines an array of integers, and includes a user-defined function
named reverseArray with the signature void reverseArray(int arr[], int size);. The function
should reverse the elements of the array. */
@@ -550,15 +550,15 @@ void reverseArray(int arr[], int size)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment06.c</span>
+ <span class="text-gray-700">assignment-p-06.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment06.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-06.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment06_c', 'assignment06.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-06_c', 'assignment-p-06.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment06_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment06.c">
+ <div id="code-assignment-primary-assignment-p-06_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-06.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named findLargest with the
signature int findLargest(int arr[], int size);. The function should take an array of integers
and its size, and return the largest element in the array. */
@@ -607,15 +607,15 @@ int findLargest(int arr[], int size)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment07.c</span>
+ <span class="text-gray-700">assignment-p-07.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment07.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-07.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment07_c', 'assignment07.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-07_c', 'assignment-p-07.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment07_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment07.c">
+ <div id="code-assignment-primary-assignment-p-07_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-07.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named binarySearch with the
signature int binarySearch(int arr[], int size, int target);. The function should perform a
binary search on a sorted array of integers and return the index of the target element if
@@ -729,15 +729,15 @@ int binarySearch(int arr[], int size, int target)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment08.c</span>
+ <span class="text-gray-700">assignment-p-08.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment08.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-08.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment08_c', 'assignment08.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-08_c', 'assignment-p-08.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment08_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment08.c">
+ <div id="code-assignment-primary-assignment-p-08_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-08.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named countSetBits with the
signature int countSetBits(int num);. The function should count and return the number of
set bits (1s) in the binary representation of the given number. */
@@ -793,15 +793,15 @@ int countSetBits(int num)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment09.c</span>
+ <span class="text-gray-700">assignment-p-09.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment09.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-09.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment09_c', 'assignment09.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-09_c', 'assignment-p-09.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment09_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment09.c">
+ <div id="code-assignment-primary-assignment-p-09_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-09.c">
<pre><code class="language-c">/* Write a C program that includes a user-defined function named setBit with the signature
int setBit(int num, int position);. The function should set the bit at the specified position
(0-indexed) to 1 and return the modified number. */
@@ -832,15 +832,15 @@ int setBit(int num, int position)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment10.c</span>
+ <span class="text-gray-700">assignment-p-10.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment10.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-10.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment10_c', 'assignment10.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-10_c', 'assignment-p-10.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment10_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment10.c">
+ <div id="code-assignment-primary-assignment-p-10_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-10.c">
<pre><code class="language-c">/* Write a C program that defines a structure Rectangle with attributes length and width.
Include a user-defined function named calculateArea with the signature float
calculateArea(struct Rectangle r);. The function should calculate and return the area of
@@ -876,15 +876,15 @@ float calculateArea(struct Rectangle r)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment11.c</span>
+ <span class="text-gray-700">assignment-p-11.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment11.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-11.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment11_c', 'assignment11.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-11_c', 'assignment-p-11.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment11_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment11.c">
+ <div id="code-assignment-primary-assignment-p-11_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-11.c">
<pre><code class="language-c">/* Write a C program that defines a structure Student containing the attributes rollNumber,
name, and marks. Include a user-defined function named displayStudent with the
signature void displayStudent(struct Student s);. The function should display the details
@@ -950,15 +950,15 @@ void displayStudent(struct Student std)
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment12.c</span>
+ <span class="text-gray-700">assignment-p-12.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment12.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-12.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment12_c', 'assignment12.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-12_c', 'assignment-p-12.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment12_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment12.c">
+ <div id="code-assignment-primary-assignment-p-12_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-12.c">
<pre><code class="language-c">/* Write a C program that takes multiple integers as command-line arguments and finds the
maximum and minimum value among them. */
@@ -1011,15 +1011,15 @@ int main(int argc, char *argv[])
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment13.c</span>
+ <span class="text-gray-700">assignment-p-13.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment13.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-13.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment13_c', 'assignment13.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-13_c', 'assignment-p-13.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment13_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment13.c">
+ <div id="code-assignment-primary-assignment-p-13_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-13.c">
<pre><code class="language-c">/* Write a C program that accepts a string as a command line argument and includes a user-
defined function named isPalindrome with the signature int isPalindrome(char str[]);.
The function should check if the given string is a palindrome and return 1 if it is, and 0
@@ -1092,15 +1092,15 @@ int isPalindrome(char str[])
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment14.c</span>
+ <span class="text-gray-700">assignment-p-14.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment14.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-14.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment14_c', 'assignment14.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-14_c', 'assignment-p-14.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment14_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment14.c">
+ <div id="code-assignment-primary-assignment-p-14_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-14.c">
<pre><code class="language-c">/* Write a C program that opens its own source code file, reads its contents, and then prints
the contents to the console. */
@@ -1164,15 +1164,15 @@ int main(int argc, char *argv[])
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">assignment15.c</span>
+ <span class="text-gray-700">assignment-p-15.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment15.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-15.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-assignment-assignment15_c', 'assignment15.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-primary-assignment-p-15_c', 'assignment-p-15.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-assignment-assignment15_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment/assignment15.c">
+ <div id="code-assignment-primary-assignment-p-15_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-primary/assignment-p-15.c">
<pre><code class="language-c">/* Write a C program that reads a sequence of integers from a file named 'input.txt'. This
program should segregate the odd numbers from the even numbers and store the odd
numbers in a new file named 'ODDFile.txt' while storing the even numbers in another file
@@ -1241,329 +1241,469 @@ int main()
</li>
<li class="border rounded-lg overflow-hidden">
- <div class="folder-header bg-gray-100 p-4 cursor-pointer hover:bg-blue-100 transition-colors duration-200" onclick="toggleFolder('c')">
+ <div class="folder-header bg-gray-100 p-4 cursor-pointer hover:bg-blue-100 transition-colors duration-200" onclick="toggleFolder('assignment-secondary')">
<div class="flex items-center justify-between">
<div class="flex items-center">
<svg class="w-6 h-6 text-blue-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path></svg>
- <span class="font-medium text-gray-800">c</span>
- <span class="ml-2 text-sm text-gray-500">(7 files)</span>
+ <span class="font-medium text-gray-800">assignment-secondary</span>
+ <span class="ml-2 text-sm text-gray-500">(8 files)</span>
</div>
<div class="flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/tree/main/c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/tree/main/assignment-secondary" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <div class="chevron" id="chevron-c"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div>
+ <div class="chevron" id="chevron-assignment-secondary"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div>
</div>
</div>
</div>
- <div class="folder-content hidden bg-white" id="folder-c">
+ <div class="folder-content hidden bg-white" id="folder-assignment-secondary">
<ul class="divide-y divide-gray-200">
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">1.c</span>
+ <span class="text-gray-700">assignment-s-01.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/1.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-01.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-1_c', '1.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-01_c', 'assignment-s-01.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-1_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/1.c">
- <pre><code class="language-c">// Write a program (WAP) to print the sum and product of digits of an integer.
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-01_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-01.c">
+ <pre><code class="language-c">/* Write a program to compute the sum and product of digits of an integer using user
+defined functions. */
-#include<stdio.h>
+#include <stdio.h>
-int main() {
- int inp, result_sum = 0, result_product = 1, temp;
- printf("Please enter the number : ");
- scanf("%d",&inp);
- printf("\n");
-
- if (inp < 0) {
- printf("\nPlease enter a valid non negetive integer.");
- return 1;
- }
-
- temp = inp;
- while (temp != 0 ) {
- result_sum = result_sum + (temp % 10);
- result_product = result_product * (temp % 10);
- temp = temp / 10;
- }
-
- printf("\nSum of the digits of the input number '%d' is : %d"
- "\nProduct of the digits of the input number '%d' is : %d",
- inp, result_sum, inp, result_product);
- return 0;
+int sum_of_digits(int);
+int product_of_digits(int);
+
+int main()
+{
+ int num;
+ printf("Enter the number: ");
+ scanf("%d", &num);
+ printf("\nSum of digits of %d = %d", num, sum_of_digits(num));
+ printf("\nProduct of digits of %d = %d", num, product_of_digits(num));
+ return 0;
}
-</code></pre>
+int sum_of_digits(int num)
+{
+ int sum = 0;
+ while (num > 0)
+ {
+ sum += num % 10;
+ num /= 10;
+ }
+ return sum;
+}
+
+int product_of_digits(int num)
+{
+ int product = 1;
+ while (num > 0)
+ {
+ product *= num % 10;
+ num /= 10;
+ }
+ return product;
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">2.c</span>
+ <span class="text-gray-700">assignment-s-02.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/2.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-02.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-2_c', '2.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-02_c', 'assignment-s-02.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-2_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/2.c">
- <pre><code class="language-c">//WAP to reverse a non-negative integer.
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-02_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-02.c">
+ <pre><code class="language-c">/* Write a program to reverse a non-negative integer using a function. */
-#include<stdio.h>
+#include <stdio.h>
-int main() {
- int inp, result = 0, temp;
- printf("PLease enter the number you want to reverse : ");
- scanf("%d",&inp);
- printf("\n");
-
- if (inp < 0) {
- printf("\nPlease enter a non negetive integer.");
- return 1;
- }
-
- temp = inp;
- while ( temp != 0) {
- result = (result * 10) + (temp % 10);
- temp = temp / 10;
- }
-
- printf("\nReverse of the input '%d' is : %d", inp, result);
- return 0;
+int reverse(int);
+
+int main()
+{
+ int num;
+ printf("Enter a non-negetive integer: ");
+ scanf("%d", &num);
+ if (num < 0)
+ {
+ printf("\nOnly non-negetive integers are allowed.");
+ return 1;
+ }
+ printf("\nReverse of the integer %d = %d", num, reverse(num));
+ return 0;
}
-</code></pre>
+int reverse(int num)
+{
+ int rev = 0;
+ while (num > 0)
+ {
+ rev = (rev * 10) + (num % 10);
+ num /= 10;
+ }
+ return rev;
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">3.c</span>
+ <span class="text-gray-700">assignment-s-03.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/3.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-03.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-3_c', '3.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-03_c', 'assignment-s-03.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-3_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/3.c">
- <pre><code class="language-c">// WAP to compute the sum of the first n terms of the following series S =1+1/2+1/3+1/4+......
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-03_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-03.c">
+ <pre><code class="language-c">/* Write a program to compute the sum of the first n terms of the series using a function:
+S=1−2+3−4+5−6+… */
-#include<stdio.h>
+#include <stdio.h>
-int main() {
- int n, i;
- float result = 0;
- printf("Please enter the value for 'n' : ");
- scanf("%d", &n);
- printf("\n");
-
- if (n <= 0) {
- printf("\nPlease enter a positve number greater than ZERO.");
- return 1;
- }
-
- for (i = 1; i <= n; i++) {
- result = result + (1.0 / i);
- }
-
- printf("\nSum of the first %d terms of the following series S =1+1/2+1/3+1/4+...... is : %f",n,result);
- return 0;
+int sum_of_series(int);
+
+int main()
+{
+ int n;
+ printf("Enter the n: ");
+ scanf("%d", &n);
+ printf("\nSum of the first %d terms of the series = %d", n, sum_of_series(n));
+ return 0;
}
-</code></pre>
+
+int sum_of_series(int n)
+{
+ int sum = 0;
+ int i;
+ for (i = 1; i <= n; i++)
+ {
+ if (i % 2 == 0)
+ {
+ sum -= i;
+ }
+ else
+ {
+ sum += i;
+ }
+ }
+ return sum;
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">4.c</span>
+ <span class="text-gray-700">assignment-s-04.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/4.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-04.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-4_c', '4.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-04_c', 'assignment-s-04.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-4_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/4.c">
- <pre><code class="language-c">//WAP to compute the sum of the first n terms of the following series,S =1-2+3-4+5......
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-04_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-04.c">
+ <pre><code class="language-c">/* Write a function to check whether a number is prime or not. Use the same function to
+generate all prime numbers less than 100. */
-#include<stdio.h>
+#include <stdio.h>
+#include <math.h>
-int main() {
- int n, result = 0, temp, i;
- printf("Please enter the value for 'n' for this series 's = 1-2+3-4+5-....': ");
- scanf("%d",&n);
- printf("\n");
-
- if (n <= 0) {
- printf("\nPlease enter a positive integer.");
- return 1;
- }
-
- for (i = 1; i<= n; i++) {
- if (i % 2 == 0) {
- result = result - i;
- }
- else {
- result = result + i;
- }
- }
-
- printf("\nAns : %d", result);
+int isPrime(int);
+
+int main()
+{
+ int n, i;
+ printf("Enter the number: ");
+ scanf("%d", &n);
+ if (isPrime(n))
+ {
+ printf("\nInput %d is a Prime Number.", n);
+ }
+ else
+ {
+ printf("\nInput %d is not a Prime Number.", n);
+ }
+ printf("\nPrime Numbers less than 100:");
+ for (i = 1; i < 100; i++)
+ {
+ if (isPrime(i))
+ {
+ printf(" %d", i);
+ }
+ }
+ return 0;
}
-</code></pre>
+
+int isPrime(int n)
+{
+ if (n <= 1)
+ return 0;
+ if (n == 2)
+ return 1;
+ if (n % 2 == 0)
+ return 0;
+
+ int temp = (int)sqrt(n);
+ int i;
+ for (i = 3; i <= temp; i += 2)
+ {
+ if (n % i == 0)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">5.c</span>
+ <span class="text-gray-700">assignment-s-05.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/5.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-05.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-5_c', '5.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-05_c', 'assignment-s-05.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-5_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/5.c">
- <pre><code class="language-c">/*Write a function to find whether a given no. is prime or not.
-Use the same to generate the prime numbers less than 100.*/
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-05_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-05.c">
+ <pre><code class="language-c">/* Write a function to check whether a given string is a palindrome. Use this function to
+determine whether an entered string is Palindrome. */
-#include<stdio.h>
+#include <stdio.h>
+#include <string.h>
-int isPrime(int inp) {
- int i, is_prime = 1;
-
- if (inp < 2) is_prime = 0;
-
- for (i = 2; i <= inp / 2; i++) if (inp % i == 0) {
- is_prime = 0;
- break;
- }
-
- return is_prime;
-}
+int isPalindrome(char[]);
+int main()
+{
+ char input[100];
+ int len;
-int main() {
- int inp, i;
- printf("Enter the number you want to check : ");
- scanf("%d",&inp);
- printf("\n");
-
- if (isPrime(inp)) printf("\nGiven input '%d' is a Prime Number.",inp);
- else printf("\nGiven input '%d' is not a Prime Number.",inp);
-
- printf ("\nSeries of prime number upto 100 : ");
- for (i = 2; i < 100; i++) if (isPrime(i)) printf(" %d",i);
-
- return 0;
+ printf("Enter the string (Max: 100 Character): ");
+ fgets(input, sizeof(input), stdin);
+ len = strlen(input);
+
+ if (len > 0 && input[len - 1] == '\n')
+ {
+ input[len - 1] = '\0';
+ }
+
+ if (isPalindrome(input))
+ {
+ printf("\nInput string \"%s\" is Palindrome.", input);
+ }
+ else
+ {
+ printf("\nInput string \"%s\" is not Palindrome", input);
+ }
+
+ return 0;
}
-</code></pre>
+
+int isPalindrome(char str[])
+{
+ char *start = str;
+ char *end;
+ int len = strlen(str);
+
+ if (len == 0)
+ {
+ return 1;
+ }
+
+ end = str + (len - 1);
+
+ while (start < end)
+ {
+ if (*start != *end)
+ {
+ return 0;
+ }
+ start++;
+ end--;
+ }
+
+ return 1;
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">6.c</span>
+ <span class="text-gray-700">assignment-s-06.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/6.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-06.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-6_c', '6.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-06_c', 'assignment-s-06.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-6_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/6.c">
- <pre><code class="language-c">/*Write a function that checks whether a given string is Palindrome or not.
-Use this function to find whether the string entered by the user is Palindrome or not.*/
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-06_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-06.c">
+ <pre><code class="language-c">/* Write a program using a function to compute and display all factors of a given number. */
-#include<stdio.h>
-#include<string.h>
-
-int isPalindrome(char inp[]) {
- int len = strlen(inp);
- int i = 0; //starting point
- int j = len - 1; //end point
-
- while (i < j) {
- if (inp[i] != inp[j]) {
- return 0;
- }
- i++;
- j--;
- }
+#include <stdio.h>
+#include <stdlib.h>
- return 1;
-}
+void display_factors(int);
-int main() {
- char inp[20];
- printf("Enter the number : ");
- scanf("%s",inp);
- if (isPalindrome(inp)) printf("\n\nInput '%s' is a Palindrome number.", inp);
- else printf("\n\nInput '%s' is not a Palindrome number.", inp);
- return 0;
+int main()
+{
+ int num, i;
+ printf("Please enter the number to get the factors from it : ");
+ scanf("%d", &num);
+ display_factors(num);
+ return 0;
}
-</code></pre>
+
+void display_factors(int num) {
+ int temp = abs(num);
+ int i;
+
+ if (temp == 0)
+ {
+ printf("\n0 has infinitely many factors (all integers).");
+ exit(1);
+ }
+
+ printf("\nThe factors of ' %d ' is :- ", num);
+ printf("\nPositive : ");
+ for (i = 1; i <= temp; i++)
+ if (temp % i == 0)
+ printf(" %d", i);
+ printf("\nNegative : ");
+ for (i = 1; i <= temp; i++)
+ if (temp % i == 0)
+ printf(" %d", -i);
+}</code></pre>
</div>
</li>
<li>
<div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
- <span class="text-gray-700">7.c</span>
+ <span class="text-gray-700">assignment-s-07.c</span>
<div class="ml-auto flex items-center space-x-4">
- <a href="https://github.com/notamitgamer/bsc/blob/main/c/7.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-07.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
</a>
- <button onclick="showCode('code-c-7_c', '7.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-07_c', 'assignment-s-07.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
</div>
</div>
- <div id="code-c-7_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/7.c">
- <pre><code class="language-c">// WAP to compute the factors of a given number
-// Author - Amit Dutta, Date - 13th SEP, 2025
+ <div id="code-assignment-secondary-assignment-s-07_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-07.c">
+ <pre><code class="language-c">/* Write a program to swap two numbers using a macro (#define). */
-#include<stdio.h>
-#include<stdlib.h>
+// IMPOSSIBLE
+/* It is impossible to swap two literal numbers defined using the
+preprocessor directive #define. This is because #define performs simple
+text substitution and does not create variables in memory that can be
+manipulated or pointed to. */
+
+// Using a Function-Like Macro
+
+#include <stdio.h>
+
+// Define the SWAP macro.
+// The do-while(0) block is a common trick to ensure the macro behaves
+// like a single statement, regardless of where it is used (e.g., inside an 'if' statement).
+#define SWAP(a, b, data_type) \
+ do { \
+ data_type temp = a; \
+ a = b; \
+ b = temp; \
+ } while(0)
int main() {
- int inp, num, i;
- printf("Please enter the number to get the factors from it : ");
- scanf("%d", &inp);
-
- num = abs(inp);
-
- if (num == 0) {
- printf("\n\n0 has infinitely many factors (all integers).");
- return 1;
- }
-
- printf("\n\nThe factors of ' %d ' is :- ", inp);
- printf("\nPositive : ");
- for (i = 1; i <= num ; i++) if (num % i == 0) printf(" %d", i);
- printf("\nNegative : ");
- for (i = 1; i <= num ; i++) if (num % i == 0) printf(" %d", -i);
- return 0;
-}
-</code></pre>
+ int num1 = 15;
+ int num2 = 42;
+
+ printf("--- Before Swap ---\n");
+ printf("Number 1 (num1): %d\n", num1);
+ printf("Number 2 (num2): %d\n", num2);
+
+ // Call the macro, passing the variables and their type
+ // The preprocessor replaces this line with the block of code defined above.
+ SWAP(num1, num2, int);
+
+ printf("\n--- After Swap (using macro) ---\n");
+ printf("Number 1 (num1): %d\n", num1);
+ printf("Number 2 (num2): %d\n", num2);
+
+ return 0;
+}</code></pre>
+ </div>
+ </li>
+
+ <li>
+ <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200">
+ <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>
+ <span class="text-gray-700">assignment-s-08.c</span>
+ <div class="ml-auto flex items-center space-x-4">
+ <a href="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-08.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub">
+ <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>
+ </a>
+ <button onclick="showCode('code-assignment-secondary-assignment-s-08_c', 'assignment-s-08.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button>
+ </div>
+ </div>
+ <div id="code-assignment-secondary-assignment-s-08_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/assignment-secondary/assignment-s-08.c">
+ <pre><code class="language-c">/* Write a program that counts the number of occurrences of each alphabet (A-Z, a-z) in
+the text entered using Command-Line Arguments. */
+
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+ int target[2], i, j, count[2], len;
+ for (target[0] = 'A', target[1] = 'a'; target[0] <= 'Z', target[1] <= 'z'; target[0]++, target[1]++)
+ {
+ count[0] = 0;
+ count[1] = 0;
+ for (i = 1; i < argc; i++)
+ {
+ len = strlen(argv[i]);
+ for (j = 0; j < len; j++)
+ {
+ if (argv[i][j] == target[0])
+ {
+ count[0]++;
+ }
+ if (argv[i][j] == target[1])
+ {
+ count[1]++;
+ }
+ }
+ }
+ if (count[0])
+ {
+ printf("\n\"%c\" found %d times.", target[0], count[0]);
+ }
+ if (count[1])
+ {
+ printf("\n\"%c\" found %d times.", target[1], count[1]);
+ }
+ }
+ return 0;
+}</code></pre>
</div>
</li>
</ul>