Palindrome String without using string
In this example, we will understand to perform Palindrome String without using string handling function and know how to write, compile and debug it in C language and also learn how to implement it in c.
As you know the best way to do this program is by using the strrev(), strcpy(),strcmp() function but in this example we will palindrome string manually without using any string handling function
The some example of palindrome are MOM, MAM, RADAR, 515 here you will see if reverse those characters we will get that word as it is.
In order to do this you will need
- Basic knowledge of c programming language.
- As well as know how to operate codeblocks.
So let's begin with our program
1.Open a codeblocks software.
2.Open new empty file.
3.Copy and paste the code from below.
Input code-
//Program for Palindrome String.
#include<stdio.h>
#include<string.h>
int main()
{
char s[1000];
int i,n,c=0;
printf("Enter the string : ");
gets(s);
n=strlen(s);
for(i=0;i<n/2;i++)
{
if(s[i]==s[n-i-1])
c++;
}
if(c==i)
printf("string is palindrome");
else
printf("string is not palindrome");
return 0;
}
Now simply build the code. Look for any error. Now run the code.
For output enter any number or character series you want and press enter key.
Click the following button to download a program for Palindrome String without using string handling function
Thats it.Thank you for scrolling.
Tags:
string handling function