bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

commit b693e554e75822fc0c46be6eb180af16b031a515
parent 098b0287d3cad4997be43a1ddacaebc745804721
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Mon, 27 Oct 2025 21:40:45 +0530

new p-28102025

Diffstat:
Atuition-c/P038.c | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atuition-c/P039.c | 21+++++++++++++++++++++
Atuition-c/P040.c | 19+++++++++++++++++++
Atuition-c/P041.c | 30++++++++++++++++++++++++++++++
Atuition-c/P042.c | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atuition-c/P043.c | 27+++++++++++++++++++++++++++
Atuition-c/P044.c | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 288 insertions(+), 0 deletions(-)

diff --git a/tuition-c/P038.c b/tuition-c/P038.c @@ -0,0 +1,56 @@ +/* Write a program to check prime number */ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> +#include <math.h> +#include <stdbool.h> + +int main() +{ + int num, i, endCheckDigit; + bool isPrime = true; + printf("Enter the number : "); + if (scanf("%d", &num) != 1) + { + printf("\nOnly a number is allowed, not a character."); + return 1; + } + if (num <= 0) + { + printf("\nOnly postive number is allowed."); + return 1; + } + if (num == 1) + { + printf("\nInput 1 is not a prime number." + "\nHas only one positive divisor (itself), not exactly two." + "\nRule: Prime number should have exactly two distinct positive divisors: 1 and itself"); + return 0; + } + if (num == 2) + { + printf("\nInput 2 is a prime number." + "\n(Note: 2 is only Even Prime Number)"); + return 0; + } + if (num % 2 == 0) + { + printf("\nInput %d is not a prime number.", num); + return 0; + } + endCheckDigit = sqrt(num); + for (i = 3; i <= endCheckDigit; i += 2) + { + if (num % i == 0) + { + isPrime = false; + printf("\nInput %d is not prime number.", num); + return 0; + } + } + if (isPrime) + { + printf("\nInput %d is a prime number.", num); + } + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P039.c b/tuition-c/P039.c @@ -0,0 +1,20 @@ +/* Write a program to print all the factors of a postive integer */ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> + +int main() +{ + int num, i; + printf("Enter a number : "); + scanf("%d", &num); + printf("\nFactors of %d : ", num); + for (i = 1; i <= num / 2; i++) + { + if (num % i == 0) + { + printf(" %d", i); + } + } + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P040.c b/tuition-c/P040.c @@ -0,0 +1,18 @@ +/* Write a program to calculate HCF of two positive number */ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> +int main() +{ + int a, b, temp; + printf("Enter two number : "); + scanf("%d %d", &a, &b); + while (b > 0) + { + temp = a; + a = b; + b = temp % b; + } + printf("HCF = %d", a); + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P041.c b/tuition-c/P041.c @@ -0,0 +1,29 @@ +/* Write a program to enter two numbers and check they are co-prime or not. + co-prime when HCF = 1 +*/ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> +int main() +{ + int a, b, temp, temp_a, temp_b; + printf("Enter two number : "); + scanf("%d %d", &a, &b); + temp_a = a; + temp_b = b; + while (b > 0) + { + temp = a; + a = b; + b = temp % b; + } + if (a == 1) + { + printf("\n(%d, %d) is co-prime.", temp_a, temp_b); + } + else + { + printf("\n(%d, %d) is not co-prime.", temp_a, temp_b); + } + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P042.c b/tuition-c/P042.c @@ -0,0 +1,55 @@ +/* Write a program to accept a number and check whether the number +is twisted prime or not. */ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> +#include <math.h> + +int main() +{ + int n, t, i, r, rev, prime = 1; + printf("Enter the number : "); + scanf("%d", &n); + for (i = 2; i <= (int)sqrt(n); i++) + { + if (n % i == 0) + { + prime = 0; + break; + } + } + if (prime) + { + printf("%d is a prime number.", n); + t = n; + rev = 0; + prime = 1; + while (t > 0) + { + r = t % 10; + rev = rev * 10 + r; + t = t / 10; + } + for (i = 2; i <= (int)sqrt(rev); i++) + { + if (rev % i == 0) + { + prime = 0; + break; + } + } + if (prime) + { + printf("\n%d and %d are prime numbers.. TWISTED PRIME", n, rev); + } + else + { + printf("\n%d is non prime", rev); + } + } + else + { + printf("\n%d is non prime.", n); + } + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P043.c b/tuition-c/P043.c @@ -0,0 +1,26 @@ +/* Write a program to check palindrome number. */ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +#include <stdio.h> +int main() +{ + int num, temp, rev; + printf("Enter the number : "); + scanf("%d", &num); + temp = num; + rev = 0; + while (temp > 0) + { + rev = (rev * 10) + (temp % 10); + temp /= 10; + } + if (num == rev) + { + printf("%d is a palindrome number.", num); + } + else + { + printf("%d is not a palindrome number.", num); + } + return 0; +}+ \ No newline at end of file diff --git a/tuition-c/P044.c b/tuition-c/P044.c @@ -0,0 +1,77 @@ +/* Write a program to input a number and check whether the +number is Pronic number or not. + Pronic Number: The number which is the product of two numbers + which is the product of two consecutive integer. + Ex: 20 = 4 * 5 +*/ +/* Author - Amit Dutta, Date - 27th OCT, 2025 */ + +// using boolean... +/* +#include <stdio.h> +#include <math.h> +#include <stdbool.h> + +int main() +{ + int num, iterationIndex; + bool isPronic = false; + printf("Enter the number : "); + if (scanf("%d", &num) != 1) + { + printf("\nYou have to enter a number, not an character or symbol."); + return 1; + } + if (num < 1) + { + printf("\nOnly postive number is allowed."); + return 1; + } + for (iterationIndex = 1; iterationIndex <= num / 2; iterationIndex++) + { + if (iterationIndex * (iterationIndex + 1) == num) + { + printf("\nInput %d is a Pronic Number.", num); + isPronic = true; + break; + } + } + if(!isPronic) + { + printf("\nInput %d is not a Pronic Number.", num); + } + return 0; +} +*/ + +// using direct return method (more efficient and generally preferred)... + +#include <stdio.h> +#include <math.h> + +int main() +{ + int num, iterationIndex, iterationLimit; + printf("Enter the number : "); + if (scanf("%d", &num) != 1) + { + printf("\nYou have to enter a number, not an character or symbol."); + return 1; + } + if (num < 1) + { + printf("\nOnly postive number is allowed."); + return 1; + } + iterationLimit = (int)sqrt(num); + for (iterationIndex = 1; iterationIndex <= iterationLimit; iterationIndex++) + { + if (iterationIndex * (iterationIndex + 1) == num) + { + printf("\nInput %d is a Pronic Number.", num); + return 0; + } + } + printf("\nInput %d is not a Pronic Number.", num); + return 0; +}+ \ No newline at end of file
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror