Write a C program to check if a number is palindrome?

#include<stdio.h>
#include<conio.h>
void main()
{
    char a[10], b[10];
    printf("Enter a string to check if is a palindrome of not: ");
    gets(a);
    strcpy(b,a);
    strrev(b);
    if(strcmp(a,b) == 0)
    {
        printf("%s is a palindrome.",a);
    }else {
        printf("%s is not a palindrome.",a);
    }
    getch();
}

Outpur 1:


Outpur 2:

 

Note:-

  1) gets() function is used to get a string through user keyboard.
  2) strcpy() function is used to copy one string into other.
  3) strrev() function is used to reverse the string.
  4) strcmp() function is user for comparison of two strings.

Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider