Algorithms_in_C  1.0.0
Set of algorithms implemented in C.
palindrome.c File Reference

Program to identify if a number is palindrome number or not. More...

#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
Include dependency graph for palindrome.c:

Functions

bool isPalindrome (int number)
 Check given number whether is palindrome number or not. More...
 
int main ()
 Driver Code.
 

Detailed Description

Program to identify if a number is palindrome number or not.

See also
project_euler/problem_4/sol1.c

Function Documentation

◆ isPalindrome()

bool isPalindrome ( int  number)

Check given number whether is palindrome number or not.

Parameters
numbernumber to check
Returns
true if given number is palindrome number
false if number is not a palindrome number
30 {
31  int reversedNumber = 0;
32  int originalNumber = number;
33  while (number != 0)
34  {
35  int remainder = number % 10;
36  reversedNumber = reversedNumber * 10 + remainder;
37  number /= 10;
38  }
39  return originalNumber == reversedNumber;
40 }