bsc

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

commit 79e7c4966d4f556c58341db3e36017520f2d1482
parent 7bca45b494cfb61b9319462f6c6a14f9f8060bba
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Tue,  2 Jun 2026 21:20:50 +0530

added more

Diffstat:
Asemester_1/practice-c/external_4.c | 29+++++++++++++++++++++++++++++
Asemester_1/practice-c/external_5.c | 29+++++++++++++++++++++++++++++
Autils/generate_structure.py | 20++++++++++++++++++++
3 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/semester_1/practice-c/external_4.c b/semester_1/practice-c/external_4.c @@ -0,0 +1,28 @@ +// 4. Write a function to find whether a given number is prime or not. Use it to generate prime numbers less than 100. + +#include<stdio.h> + +int isPrime(int); + +int main() { + int num, i; + printf("Enter the number: "); + scanf("%d", &num); + if(isPrime(num)) printf("\n%d is a prime number.", num); + else printf("\n%d is not a prime number.", num); + + // generate prime numbers upto 100 + printf("\n\nPrime number upto 100: "); + for(i = 1; i <= 100; i++) { + if(isPrime(i)) printf("\n%d ", i); + } + return 0; +} + +int isPrime(int n) { + int i; + if(n == 2) return 1; + if(n <= 1 || n % 2 == 0) return 0; + for(i = 3; i * i <= n; i = i+2) if(n % i == 0) return 0; + return 1; +}+ \ No newline at end of file diff --git a/semester_1/practice-c/external_5.c b/semester_1/practice-c/external_5.c @@ -0,0 +1,28 @@ +// 5. Write a function that checks whether a given string is a Palindrome or not. + +#include<stdio.h> +#include<string.h> +#include<ctype.h> + +int isPalindrome(char []); + +int main() { + char str[50]; + printf("Enter the string (upto 50 char): "); + fgets(str, sizeof(str), stdin); + if(str[strlen(str) - 1] == '\n') str[strlen(str) - 1] = '\0'; + if(isPalindrome(str)) printf("\n\"%s\" is palindrome.", str); + else printf("\n\"%s\" is not palindrome.", str); + return 0; +} + +int isPalindrome(char str[]) { + int len = strlen(str); + int start = 0, end = len - 1; + while(start < end) { + if(tolower(*(str + start)) != tolower(*(str + end))) return 0; + start++; + end--; + } + return 1; +}+ \ No newline at end of file diff --git a/utils/generate_structure.py b/utils/generate_structure.py @@ -0,0 +1,19 @@ +import os + +def save_structure_to_txt(target_dir, output_file): + with open(output_file, 'w', encoding='utf-8') as f: + for root, dirs, files in os.walk(target_dir): + level = root.replace(target_dir, '').count(os.sep) + indent = ' ' * level + f.write(f"{indent}{os.path.basename(root)}/\n") + for file in files: + f.write(f"{indent} {file}\n") + +target = r'G:\bsc' +output = 'directory_structure.txt' + +if os.path.exists(target): + save_structure_to_txt(target, output) + print(f"Structure saved to {output}") +else: + print(f"The path {target} does not exist.")+ \ 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