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

Problem 4 solution More...

#include <stdio.h>
Include dependency graph for sol.c:

Functions

int is_palindromic (unsigned int n)
 Check if number is palindromic. More...
 
int main (void)
 Main function.
 

Detailed Description

Problem 4 solution

Function Documentation

◆ is_palindromic()

int is_palindromic ( unsigned int  n)

Check if number is palindromic.

Parameters
[in]nnumber to check
Returns
1 if palindromic
0 if not palindromic
13 {
14  unsigned int reversed = 0, t = n;
15 
16  while (t > 0)
17  {
18  reversed = 10 * reversed + (t % 10);
19  t /= 10;
20  }
21  return reversed == n;
22 }