Write a C program to read any integer from user and compute the reverse of given number. Also output whether the reverse number is prime or not. Sample Input/Output: Enter any integer: 4521 Reverse number is: 1254. It is not a prime number.
#include<stdio.h> int main() { int i,p,num, ans = 0; scanf("%d",&num); printf("Please enter a number: \n"); scanf("%d", &num); for(i=1; i<=num; i++) { if(num%i==0) { p++; } } if(p==2) { printf("Entered number is %d "\ "and it is a prime number.",num); } else { printf("Entered number is %d "\ "and it is not a prime number.",num); } while(num > 0) { int mod = num % 10; ans = ans * 10 + mod; num = num / 10; } printf("Reversed Number is %d\n",ans); return 0; }
p
break
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)