Answers for "check if string is palindrome in c"

C
2

check is number is palindrome in C

#include <stdio.h>
#include <conio.h>

void main()
{

    int n,i,r=0;
    
    printf("Enter a number: ");
    scanf("%d",&n);
    
    for(i=n;i!=0;i)
    {
        r=r*10;
        r=r+ i%10;
        i=i/10;
    }
    
    if(r==n)
        printf("palindrome");
    else
        printf("Not palindrome");
}
Posted by: Guest on June-24-2021
0

check if string is palindrome in c

// this is for string

#include <stdio.h>
#include <string.h>

void main()
{
  char a[100], b[100];

  printf("Enter a string to check if it's a palindrome: ");
  gets(a);

  strcpy(b, a);

  if (strcmp(a, b) == 0)
    printf("\nThe string is palindrome.\n");

  else
    printf("\nThe string is not palindrome.\n");

  getch();
}
Posted by: Guest on June-23-2021
0

palindrome in c using function

#include <stdio.h>
#include <conio.h>

int palindrome (int num);

void main()
{
    int n, ret;
    printf("Enter the number: ");
    scanf("%d",&n);

    ret = palindrome(n);

    if (ret == n)
        printf("\nPalindrome\n");
    else
        printf("\nNot Palindrome\n");
}

int palindrome(int num)
{
    int rem, rev=0;

    while (num!=0)
    {
        rem = num % 10;
        rev = rev * 10 + rem;
        num /= 10;
    }

    return rev;
}
Posted by: Guest on June-23-2021

Code answers related to "check if string is palindrome in c"

Code answers related to "C"

Browse Popular Code Answers by Language