Lab Questions 28.11.2024
Lab Questions 28.11.2024
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int i, length;
int isPalindrome = 1;
printf("Enter a string: ");
scanf("%s", str);
length = strlen(str);
for (i = 0; i < length / 2; i++) {
if (str[i] != str[length - i - 1]) {
isPalindrome = 0;
break;
}
}
if (isPalindrome) {
printf("The string is a palindrome.\n");
} else {
printf("The string is not a palindrome.\n");
}
}
Homework: Check if the input sentence is a “palindrome sentence”.(example: "Madam, I'm Adam."
when considering palindrome sentence, spaces and punctuation are often ignored.) (hint you can
use isalnum() function in ctype.h library)
Questions:
1. Apply the program in figure 6.13 and make it work.
2. Take the entire string “hello my name is Hakan Koyuncu” by using scanf() function. (research on
google)
3. Check if a string is palindrome (example: Hannah, radar, etc.)
4. Homework: Check if the input sentence is a “palindrome sentence”.(example: "Madam, I'm Adam."
when considering palindrome sentence, spaces and punctuation are often ignored.) (hint you can
use isalnum() function in ctype.h library)