Algorithm
Step 1: Start
Step 2: Declare integers n, t, t1, sum, count, digit
Step 3: Take input for number (n)
Step 4: Reverse the number and count digits
Step 5: Check if the reversed number is equal to original
Step 6: Print whether it is a Palindrome or not
Step 7: End
Flowchart
graph TD;
A([Start]) --> B[/Input n/];
B --> C[Initialize sum=0, count=0];
C --> D[Store t1 = n];
D --> E{n != 0?};
%% Decision Section
E --> |No| J{sum == t1?};
J -- Yes --> K[/Print: Palindrome Number/];
J -- No --> L[/Print: Not a Palindrome/];
K --> M([End]);
L --> M([End]);
%% Loop Section
E ----> |Yes| F[Extract last digit];
F --> G[sum = sum * 10 + digit];
G --> H[Reduce n = n / 10];
H --> I[Increment count];
I ----> E;
%% Define styles
classDef start fill:#00cc44,stroke:#006622,stroke-width:2px,color:#ffffff;
classDef stop fill:#ff4444,stroke:#cc0000,stroke-width:2px,color:#ffffff;
classDef input_output fill:#ffdd44,stroke:#cc9900,stroke-width:2px,color:#000000;
classDef process fill:#4488ff,stroke:#0044cc,stroke-width:2px,color:#ffffff;
classDef decision fill:#ff8844,stroke:#cc4400,stroke-width:2px,color:#ffffff;
classDef loop fill:#8888ff,stroke:#5555ff,stroke-width:2px,color:#ffffff;
%% Apply styles
class A start;
class M stop;
class B,K,L input_output;
class C,D,F,G,H,I process;
class E,J decision;
class F,G,H,I loop;
Program
<stdio.h>
<math.h>
int main()
{
int n, t, t1, sum = 0, count = 0, digit;
printf("Enter a number :");
scanf("%d", &n);
t = n;
t1 = n;
while(n != 0)
{
digit = n % 10;
sum = sum * 10 + digit;
n = n / 10;
count++;
}
printf("\n Number of digits in %d : %d", t1, count);
printf("\n Reversed number: %d", sum);
if(sum == t1)
{
printf("\n %d is a Palindrome Number", t1);
}
else
{
printf("\n %d is Not a Palindrome Number", t1);
}
return 0;
}
Test Case Output
Enter a number: 121
Number of digits in 121: 3
Reversed number: 121
121 is a Palindrome Number