bsc

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

commit 284ab6db9d01d888388a0b641532b041462ffa87
parent 97ca7410ab00621182e8837dda057f3c249515f5
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Sat,  6 Sep 2025 21:04:47 +0530

Add files via upload
Diffstat:
Mc/1.c | 2+-
Mc/1.exe | 0
Mc/2.c | 2+-
Mc/2.exe | 0
Mc/3.c | 27++++++++++++---------------
Mc/3.exe | 0
Mc/4.c | 41+++++++++++++++++------------------------
Mc/4.exe | 0
Mc/5.c | 43+++++++++++++++++++++++--------------------
Mc/5.exe | 0
Mc/6.c | 40+++++++++++++++++++++++-----------------
Mc/6.exe | 0
Ac/7.c | 24++++++++++++++++++++++++
Ac/7.exe | 0
Mc/codesnapshot/1.png | 0
Mc/codesnapshot/2.png | 0
Mc/codesnapshot/3.png | 0
Mc/codesnapshot/4.png | 0
Mc/codesnapshot/5.png | 0
Mc/codesnapshot/6.png | 0
Ac/codesnapshot/7.png | 0
21 files changed, 101 insertions(+), 78 deletions(-)

diff --git a/c/1.c b/c/1.c @@ -10,7 +10,7 @@ int main() { if (inp < 0) { printf("\nPlease enter a valid non negetive integer."); - return 0; + return 1; } temp = inp; diff --git a/c/1.exe b/c/1.exe Binary files differ. diff --git a/c/2.c b/c/2.c @@ -10,7 +10,7 @@ int main() { if (inp < 0) { printf("\nPlease enter a non negetive integer."); - return 0; + return 1; } temp = inp; diff --git a/c/2.exe b/c/2.exe Binary files differ. diff --git a/c/3.c b/c/3.c @@ -1,26 +1,23 @@ -//WAP to compute the sum of the first n terms of the following series,S =1-2+3- 4+5...... +// WAP to compute the sum of the first n terms of the following series S =1+1/2+1/3+1/4+...... #include<stdio.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); + 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 positive integer."); - return 0; + printf("\nPlease enter a positve number greater than ZERO."); + return 1; } - for (i = 1; i<= n; i++) { - if (i % 2 == 0) { - result = result - i; - } - else { - result = result + i; - } - } + for (i = 1; i <= n; i++) { + result = result + (1.0 / i); + } - printf("\nAns : %d", result); + 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; } diff --git a/c/3.exe b/c/3.exe Binary files differ. diff --git a/c/4.c b/c/4.c @@ -1,33 +1,26 @@ -/*Write a function to find whether a given no. is prime or not. -Use the same to generate the prime numbers less than 100.*/ +//WAP to compute the sum of the first n terms of the following series,S =1-2+3- 4+5...... #include<stdio.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 main() { - int inp, i; - printf("Enter the number you want to check : "); - scanf("%d",&inp); + 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 (isPrime(inp)) printf("\nGiven input '%d' is a Prime Number.",inp); - else printf("\nGiven input '%d' is not a Prime Number.",inp); + if (n <= 0) { + printf("\nPlease enter a positive integer."); + return 1; + } - printf ("\nSeris of prime number below : "); - for (i = 2; i < 100; i++) if (isPrime(i)) printf(" %d",i); + for (i = 1; i<= n; i++) { + if (i % 2 == 0) { + result = result - i; + } + else { + result = result + i; + } + } - return 0; + printf("\nAns : %d", result); } diff --git a/c/4.exe b/c/4.exe Binary files differ. diff --git a/c/5.c b/c/5.c @@ -1,30 +1,33 @@ -/*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.*/ +/*Write a function to find whether a given no. is prime or not. +Use the same to generate the prime numbers less than 100.*/ #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 +int isPrime(int inp) { + int i, is_prime = 1; - while (i < j) { - if (inp[i] != inp[j]) { - return 0; - } - i++; - j--; + if (inp < 2) is_prime = 0; + + for (i = 2; i <= inp / 2; i++) if (inp % i == 0) { + is_prime = 0; + break; } - - return 1; + + return is_prime; } + 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); + 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; } diff --git a/c/5.exe b/c/5.exe Binary files differ. diff --git a/c/6.c b/c/6.c @@ -1,24 +1,30 @@ -// WAP to compute the factors of a given number +/*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.*/ #include<stdio.h> -#include<stdlib.h> +#include<string.h> -int main() { - int inp, num, i; - printf("Please enter the number to get the factors from it : "); - scanf("%d", &inp); - - num = abs(inp); +int isPalindrome(char inp[]) { + int len = strlen(inp); + int i = 0; //starting point + int j = len - 1; //end point - if (num == 0) { - printf("\n\n0 has infinitely many factors (all integers)."); - return 0; + while (i < j) { + if (inp[i] != inp[j]) { + return 0; + } + i++; + j--; } - - 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 1; +} + +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; } diff --git a/c/6.exe b/c/6.exe Binary files differ. diff --git a/c/7.c b/c/7.c @@ -0,0 +1,24 @@ +// WAP to compute the factors of a given number + +#include<stdio.h> +#include<stdlib.h> + +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; +} diff --git a/c/7.exe b/c/7.exe Binary files differ. diff --git a/c/codesnapshot/1.png b/c/codesnapshot/1.png Binary files differ. diff --git a/c/codesnapshot/2.png b/c/codesnapshot/2.png Binary files differ. diff --git a/c/codesnapshot/3.png b/c/codesnapshot/3.png Binary files differ. diff --git a/c/codesnapshot/4.png b/c/codesnapshot/4.png Binary files differ. diff --git a/c/codesnapshot/5.png b/c/codesnapshot/5.png Binary files differ. diff --git a/c/codesnapshot/6.png b/c/codesnapshot/6.png Binary files differ. diff --git a/c/codesnapshot/7.png b/c/codesnapshot/7.png Binary files differ.
© 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