Basic Programs

If Else based Programs

Loop Based Programs

Array Based Programs

String Programs

Function Programs

Pointers Programs

Structure & File Handling Programs

Data Structure Programs

String based programs

C Program to reverse string and check if it is palindrome

#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,lastIndex=0,count=0,flag=0;
char str[80],str1[80];
printf("enter the string");
gets(str);
while(str[i]!=NULL)
{
 i++;
}
lastIndex=i-1;
i=0;
while(str[i]!=NULL)
{
 str1[i]=str[lastIndex];
 if(str[i]!=str1[i])
 {
  flag=1;
  }
 i++; 
 lastIndex--;
}
str1[i]=NULL;
printf("reverse string is\n");
puts(str1);
if(flag==0)
printf("the given string is palindrome");
else
printf("not palindrome");
}

Output of the above program is as following.

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial