Cheak three digit number is ‘Palindrom’ or ‘not’ in C language..

Cheak three digit number is ‘Palindrom’ or ‘not’..

Let’s understand some concepts..

According to mathematics ”exapands and standards form” three digit number is joined as like that. So, first separate or exapands the number by using ‘division‘ method and then join them by addition and subtraction.

  • b=a/100; if number is ‘121’ then after dividing 100 answer is 1 and 1 stores in b.
  • c=a%100; after dividing by 100 remainder is 21 and 21 stores in C.
  • d=c/10; when c or 21 again diving by 10 then 2 is answer and 2 stores in d.
  • e=c%10; after dividing by 10 remainder is 1 then 1 stores in e.
  • f=e*100+d*10+b;
  • Assume and start from e and solve like standards form.

Some important symbols used in code.

  • () small bracket
  • && use for ‘and’ use for address
  • {} curly bracket
  • “” double code
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int a, b, c, d, e, f;
  6. clrscr();
  7. printf(“Enter any three digit number to cheak number is palindrome or not”);
  8. scanf(“%d”, &a);
  9. b=a/100;
  10. c=a%100;
  11. d=c/10;
  12. e=c%10;
  13. f=e*100+d*10+b;
  14. If(a==f)
  15. {
  16. printf(“It is a Palindrom =%d”, f);
  17. }
  18. else
  19. printf(“It is not a palindrom”);
  20. getch();
  21. }

Inputs..

If a =121 then

Results..

Leave a Reply

Create your own website, free on WordPress.com.Create your own website.
Start free