// Write a program in c to print all the numbers in given input a and b 
// which are both palindrome and perfect numbers
#include <stdio.h>
int palindrome (int num);
int perfect(int num);
int main() {
    int a,b,c,d,e,f;
    printf("Enter a : ");
    scanf("%d ",&a);
    printf("\nEnter b : ");
    scanf("%d ",&b);
    c=palindrome(a);
    d=palindrome(b);
    e=perfect(a);
    f=perfect(b);
    printf("\n%d %d %d %d",c,d,e,f);
    
    return 0;
}
int palindrome(int n){
    int i,rem,temp,pal;
    temp=n;
    while(n!=0){
        i=n%10;
        rem=rem*10+i;
        n/=10;
    }
    if(temp==rem){
        pal=1;
        printf("\nNumber is palindrome");
        return 1;
    }else{
        pal=0;
        printf("\nNumber is not palindrome");
        return (0);
    }
    printf("\nPal : %d",pal);
}
int perfect(int num){
    int sum=0,per;
    for(int i=1;i<num;i++){
        if(num%i==0){
            sum+=i;
        }
    }
    if(sum==num){
        printf("\nNumber is perfect");
        per=1;
        return 1;
    }else{
        printf("\nNumber is not perfect");
        per=0;
        return (0);
        }
    printf("\nPer : %d",per);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: