A program for Palindrome String

 Palindrome String



        In this example, we will  understand to perform string operations like palindrome string and know how to write, compile and debug it in C language and also learn how to implement it in c.


        In order to do this you will need
  • Basic knowledge of c programming language.
  • As well as know how to operate codeblocks.        
        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. 

        C does not support strings as a data type.It allows us to represent strings as character arrays.A string variable is any valid C variable name and is always  declared as an array of characters.

The general form of declaration of string variable:
char string_name[size];


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. 


A parogram for Palindrome String,String,Palindrome String in c program,c programming language,2021,basic codes,input output code



Input code- 

// Write a program for Palindrome String.

#include<stdio.h>
#include<string.h>
int main()
{
char a[100],b[100];
printf("Enter a string to check if it is a palindrome\n");
gets(a);
strcpy(b,a);
strrev(b);
if (strcmp(a, b)==0)
printf("The string is a palindrome.\n");
else
printf("The string isn't a palindrome.\n");
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



A parogram for Palindrome String,String,Palindrome String in c program,c programming language,2021,basic codes,input output code


Click the following button to download a program for Palindrome String






Thats it.Thank you for scrolling.



Post a Comment

If you have any doubt or suggestions.please let me know.

Previous Post Next Post

Ads by google

Ads by google