Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque enter number is a perfect number or not in C-language

#include<stdio.h>
int main()
{
    int a,i,s=0;
    printf("Enter the number\n");
    scanf("%d",&a);
    for(i=1;i<a;i++)
    {
        if(a%i==0)
        {
            s=s+i;
        }
    }
    if(s==a)
    {
        printf("Enter number is perfect number");
    }
    else
    {
        printf("Enter number is not perfect number");
    }
}

OUTPUT
Enter the number
28
Enter number is perfect number

This program help you to cheque enter number is perfect number or not and also this program help you to make logics of coming program.

If you like this program then you can share it and for any issues you can direct contact with me from Home Page.

For regular updates you can also follow my site.

Visit Homepage

Comments

Popular posts

Creative pattern of butterfly in C-language

Variable & Datatype for C-programming

Addition of two numbers in c language

Introduction of C-language.

Language Translator of C-language

Program to cheque enter number is even or odd in c-language

Program to print the cube of a number in c-language

Linear search in C-language