top of page
Writer's picturesocialcontentclub

PALINDROME PROGRAMME IN 'C'

#include <stdio.h>int main() {
  int n, reversed = 0, remainder, original;
    printf("Enter an integer: ");
    scanf("%d", &n);
    original = n;

    // reversed integer is stored in reversed variablewhile (n != 0) {
        remainder = n % 10;
        reversed = reversed * 10 + remainder;
        n /= 10;
    }

    // palindrome if orignal and reversed are equalif (original == reversed)
        printf("%d is a palindrome.", original);
    elseprintf("%d is not a palindrome.", original);

    return 0;
}


Output
Enter an integer: 1001
1001 is a palindrome.

11 views0 comments

Related Posts

See All

コメント


bottom of page