Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program 3
- #include<stdio.h>
- #include<math.h>
- void main()
- {
- int orig_number,rev_number,last_digit,a;
- rev_number=0;
- goto input;
- input:
- {
- printf("Enter the number ");
- scanf("%d",&orig_number);
- }
- if(orig_number<=0)
- {
- printf("\nZero and negative numbers cannot be taken as input. Try again\n\n");
- goto input;
- }
- a=orig_number; //creating a duplicate of the original number
- while(a>0)
- {
- last_digit=a%10;
- rev_number=rev_number*10+last_digit;
- a=a/10;
- }
- printf("\nThe reversed number is %d",rev_number);
- if(rev_number==orig_number)
- printf("\nThe entered number is a palindrome");
- else
- printf("\nThe entered number is not palindrome");
- }
Add Comment
Please, Sign In to add comment