# 4. C PROGRAMMING LAB | Check Now

C PROGRAMMING LAB –04] Develop a program to find the reverse of a positive integer and check for PALINDROME or NOT. Display appropriate messages.

## Algorithm

• Step-1: Start
• Step-3: Initialize M=N, REV=0
• Step-4: [Check for the value of N]- If N is not equal to 0 than goto the step 5 otherwise step 6
• Step-5: digit = N%10;
• N = N/10;
• REV = REV * 10 + digit;
• [Executes these 3 steps until N value becomes to 0]
• Step-6: Check for M= REV if so , than goto step 7 else step 8
• Step-7: Print that the number is palindrome number
• Step-8: Print that the number is not palindrome
• Step-9: Stop

## Program -4 Source code

```#include<stdio.h>

int main()
{
int n,m,rev,digit;
printf("Enter the value of n\n");
scanf("%d",&n);

rev=0;
m=n;
while(n!=0)
{
digit=n%10;
n=n/10;
rev=digit+10*rev;
}
printf("Reverse of %d is %d\n",m,rev);

if(m==rev)
printf("It is a palindrome\n");
else
printf("It is not a palindrome\n");
}```

## C PROGRAMMING -Output

• Enter the value of n
• 12321
• The reverse of 12321 is 12321
• It is palindrome
• Enter the value of n
• 3456
• The reverse of 3456 is 6543
• It is not a palindrome

## C PROGRAMMING -Viva Questions

1] What are Looping control statements?

2] Explain palindrome

3] What is the difference between while and for loops?

4] What are the entry controlled and exit controlled loops in C?