The particular blog is related to C++ programming concepts.
OOPs
Class
Function
Operator overloading
Inheritance
Function Overloading
Whole India is tweeting about the probable names for Aishwarya Rai's daughter. Some astrologers are suggesting that she will grow up to be a more famous celebrity than Aishwarya if her name is a palindrome. As we all know, a palindrome is a word that can be read the same way in either direction.
Write a C program to determine whether a given word is a palindrome or not. Do not use any string library functions.
Input Format:
Input consists of a single string. Assume that the maximum length of the string is 50.
Sample Input:
Enter the word
hannah
Sample Output:
hannah is a palindrome
Sample Input:
Enter the word
bina
Sample Output:
bina is not a palindrome
Program Code:
#include<stdio.h>
int main()
{
char str1[50];
//string str1,str2;
int length=0;int flag=0; int i=0;
printf("Enter the word");
scanf("%s",str1);
while(str1[i]!='\0')
{
length++;
i++;
}
for(i=0;i<length ;i++)
{
if(str1[i] != str1[length-i-1])
{
flag = 1;
break;
}
}
if(flag==0)
printf("\n%s is a palindrome",str1);
else
printf("\n%s is not a palindrome",str1);
return 0;
}
