Write a menu driven program to check whether the numbers are palindrome or not and prime or not
Answers
Answer:
/* Iterative function to reverse digits of num*/
int reverseDigits(int num)
{
int rev_num = 0;
while (num > 0) {
rev_num = rev_num * 10 + num % 10;
num = num / 10;
}
return rev_num;
}
/* Function to check if n is Palindrome*/
int isPalindrome(int n)
{
// get the reverse of n
int rev_n = reverseDigits(n);
// Check if rev_n and n are same or not.
if (rev_n == n)
return 1;
else
return 0;
}
/*Driver program to test reversDigits*/
int main()
{
int n = 4562;
printf("Is %d a Palindrome number? -> %s\n", n,
isPalindrome(n) == 1 ? "true" : "false");
n = 2002;
printf("Is %d a Palindrome number? -> %s\n", n,
isPalindrome(n) == 1 ? "true" : "false");
return 0;
}
Explanation:
hope it helps u
:)
Answer -
I'm making this program in C programming language →
#include<stuio.h>
#include<conio.h>
void main ()
{
int n, i, s = 0 , r, p ;
clrscr();
printf("Enter any number");
scanf("%d",&n);
p==n;
while(n !=0)
{
r = n%10;
s = r + 10;
n = n/10;
}
if(p == s)
{
printf("Number is palindrome");
}
else
{
printf("Number is not Palindrome");
}
getch();
}
→ Hope it will help you ❣️❣️
→ Please mark as Breinliest ❤️❤️