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

Syntax of C-language

Variable & Datatype for C-programming

Language Translator of C-language

Errors in C-language

Addition of two numbers in c language

Introduction of C-language.

Linear search in C-language

Binary searching in C-language

Program to reverse one array into other array in C-language