Home » NO IDEA » String concatenation

String concatenation

Blog Stats

  • 15,263 hits
December 2013
M T W T F S S
« Oct   Jan »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
/*Develop a ‘C’ program to check whether a string is a palindrome or not and print*/

#include<stdio.h>
#include<string.h>
int main()
{
	int i,j=0,n;
	char name[50],revname[50];
	printf("\n Enter the string ");
	scanf("%s",name);
	n=strlen(name);

	for(i=n-1;i>=0;i--)
	{
		revname[j++]=name[i];
	}
	revname[j++]='';
	printf("\n The reversed string is %s",revname);

	if((strcmp(name,revname))==0)
	{
		printf("\n Given String is palindrome ");
	}

	else
	{
		printf("\n It is not a palindrome");
	}
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: