String Manipulation 2
String Manipulation 2
String manipulation refers to the process of performing operations on strings, such as copying,
concatenating, comparing, finding length, reversing, or replacing characters.
---
A palindrome is a string that reads the same forward and backward (e.g., "madam", "level").
Code Example
#include <stdio.h>
#include <string.h>
int main() {
char str[100], reversed[100];
int length, isPalindrome = 1;
printf("Enter a string: ");
scanf("%s", str);
length = strlen(str);
for (int i = 0; i < length; i++)
{
reversed[i] = str[length - i - 1];
}
reversed[length] = '\0';
for (int i = 0; i < length; i++)
{
if (str[i] != reversed[i])
{
isPalindrome = 0;
}
}
if (isPalindrome)
{
return 0;
}
Input:
Output:
Input:
Output: