Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <conio.h>
- int reverse(int a); /* find the reverse of a */
- int main() {
- int m,n,a;
- char ch, chr;
- /* input & check validation*/
- while (1) {
- printf("Enter m, n: ");
- fflush(stdin);
- scanf("%d%c%d%c", &m, &ch, &n, &chr);
- if (ch == ' ' && chr == '\n' && m<n) {
- break;
- }
- else {
- printf("Invalid input!\n");
- }
- }
- /* find palindrome numbers */
- printf("Palindrome numbers are:");
- for (int i = m; i<=n; i++) {
- if(i == reverse(i)) {
- printf(" %d,", i);
- }
- }
- return(0);
- }
- /* function find the reverse of a */
- int reverse(int a){
- int c,x,rv;
- x=1; rv=0;
- while (a>0) {
- c=a%10;
- rv= rv*10 +c;
- a/=10;
- }
- return (rv);
- }
Add Comment
Please, Sign In to add comment