Programming in C 312303 Practical No.21 Develop a C program using in-built mathematical and string functions
Hello MSBTE students, in this blog post we solved Programming in C 312303 Practical No.21 in which we gained knowledge about Develop C program using in-built mathematical and string functions.
In this practical, students will learn how to create their own functions and use pre-made functions. They will also learn how to work with strings, do math calculations, and use various other tools. By the end, students will be able to do things like compare words, make copies of words, and find values like sine and cosine.
Exercise
1. Checking palindrome using string function
Answer:
#include <stdio.h>#include <ctype.h>#include <string.h>int is_palindrome(const char *str) {int len = strlen(str);for (int i = 0; i < len / 2; i++) {// Convert characters to lowercase for case-insensitive comparisonchar left = tolower(str[i]);char right = tolower(str[len – 1 – i]);if (left != right) {return 0; // Not a palindrome}}return 1; // Palindrome}int main() {char str[100];printf(“Enter a string: “);fgets(str, 100, stdin);// Remove trailing newline characterstr[strcspn(str, “n”)] = ‘