-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.txt
More file actions
36 lines (29 loc) · 697 Bytes
/
Copy pathprogram.txt
File metadata and controls
36 lines (29 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Program
#include <stdio.h>
#include <string.h>
// Function to check if a string is a palindrome
int isPalindrome(char str[]) {
int left = 0;
int right = strlen(str) - 1;
while (left < right) {
if (str[left] != str[right]) {
return 0; // Not a palindrome
}
left++;
right--;
}
return 1; // Palindrome
}
int main() {
char input[100];
// Input from the user
printf("Enter a string: ");
scanf("%s", input);
// Check if the input is a palindrome
if (isPalindrome(input)) {
printf("%s is a palindrome.\n", input);
} else {
printf("%s is not a palindrome.\n", input);
}
return 0;
}