Write a program to check if the given number is palindrome or not in C language.

Tested on: Turbo C++ Version 4.0Time Complexity: O (log₁₀ n)Space Complexity: O (1)Open Source: MIT
1
2
    #include <stdio.h>
3
    #include <conio.h>
4
    void main()
5
    {
6
        int num, rem, sum = 0, temp;
7
        clrscr();
8
        printf("Enter the number:");
9
        scanf("%d", &num);
10
        temp = num;
11
        while (num != 0)
12
        {
13
            rem = num % 10;
14
            sum = sum * 10 + rem;
15
            num = num / 10;
16
        }
17
        if (temp == sum)
18
            printf("\nIt is a palindrome number");
19
        else
20
            printf("\nit is not a palindrome number");
21
    }
22
23
        

Output

1
2
    Enter the number:145541
3
4
    It is a palindrome number
5
     

Rate the Code

Reviews are published after a quick safety check (usually within 24 hours).

Reviews are public. Developers can see basic device specifications to respond. Learn more

How to run check if the given number is a palindrome or not program in C-Language?

To run check if the given number is a palindrome or not program in C-Language, follow the below mentioned steps:

  1. Copy the Code: Press the copy button in the code block to copy the complete code.
  2. Open Turbo C++ Version 4: Open the Turbo C++ (Version 4) software on your system.
  3. Paste the code: Paste the copied code into Turbo C++’s editor.
  4. Compile the Code: Compile the program by pressing the Alt+F9 keys. This shows you the errors and warnings, if any.
  5. Run the code: Press the Ctrl+F9 keys to run the program if the program is successfully compiled.
  6. Enter the Input: Provide the required inputs or your desired inputs, if applicable.
  7. Receive the Result: Get the result of the program on the screen based on the provided inputs.

More about Palindrome Numbers using the C language

Aim: To check whether the user's input number is a palindrome number or not.

Concepts used in this program

  • While Loop: To process all the digits of the user's input.
  • Modulus Operator (%): To get the last digit of the number.
  • Integer Division (/): To remove the last digit of the number.
  • Multiplication: To add the next digit by multiplying by 10. Because in the number system, 10 is the base.
  • Temporary Variable (temp): To keep the user input unchanged and showing in the output as original number.
  • If-Else Statement: To compare the original user input number and the reverse of the input number to check if it is a palindrome or not.

Real-Life Applications

  • Logic Building: This program is used to improve the logic-building skills of a programmer or student.
License: This program's source code is open-sourced under the MIT License, while the rest of the program's text content and overall dhimanp platform and brand content remain proprietary under dhimanp.

Submit your modified code

Your submissions are published after a quick safety check (usually within 7 days).

Submissions are public. Developers can see basic device specifications to respond. Learn more

Disclaimer

The information that you shared with us will be publicly visible, and everyone can see your information. And we (dhimanp) are not responsible if anyone misuses this information. We can remove any submitted code at any time for better transparency.

Privacy Policy

If you share your data with us by submitting your code for credit, then we may show your full name, school or college name, and city name on our website.

We are not using this data to track you and are not selling this data to anyone.

If you want to remove your name from our website, you can contact us, and we will remove your name from our website. In the removal process, full credit, including your full name, school or college, city, and code, will be removed from our website.