Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. /*palindrom*/
  2. #include <stdio.h>
  3. #include <conio.h>
  4.  
  5. void main()
  6. {
  7.     int num, org, digit = 0, rev = 0, count = 0;
  8.     clrscr();
  9.     printf("Enter num: ");
  10.     scanf("%d", &num);
  11.     org = num;
  12.  
  13.     while(num != 0)
  14.     {
  15.         digit = num % 10;
  16.         rev = (rev * 10) + digit;
  17.         num /= 10;
  18.         count++;
  19.     }
  20.  
  21.     if(org == rev)
  22.         printf("Palindrom");
  23.     else
  24.         printf("Not palindrom");
  25.  
  26.     printf("\nReverse: %0*d", count, rev);
  27.  
  28.     getch();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement