bsc

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

commit f08d6a1152c338ddf5c336d460cec632b721854a
parent 3f0a877b48ffcf71d451fb3c183603e0400ed316
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Mon,  8 Dec 2025 21:17:00 +0530

[2025-12-08] .\assignment\assignment13.c: New file for assignment 13

Diffstat:
Aassignment/assignment13.c | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atuition-c/APC-PRAC-042.c | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/assignment/assignment13.c b/assignment/assignment13.c @@ -0,0 +1,66 @@ +/* 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 +otherwise. */ + +#include <stdio.h> +#include <stdlib.h> + +int isPalindrome(char[]); + +int main(int argc, char *argv[]) +{ + if (argc != 2) + { + printf("\nUsage: %s <string>\n", argv[0]); + return 1; + } + if (isPalindrome(argv[1])) + { + printf("\nThe entered string \"%s\" is a Palindrome.\n", argv[1]); + } + else + { + printf("\nThe entered string \"%s\" is not Palindrome.\n", argv[1]); + } + return 0; +} + +int isPalindrome(char str[]) +{ + char *start = str; + char *end = str; + if (*end != '\0') + { + while (*(end + 1) != '\0') + { + end++; + } + } + else + { + return 1; + } + /* + Or we can use string.h instead of from line 33 to line 43 like this ... + + 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/tuition-c/APC-PRAC-042.c b/tuition-c/APC-PRAC-042.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
© 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