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

Introduction of C-language.

Variable & Datatype for C-programming

Program to see all ASCII value using for loop in C-language

Errors in C-language

Program to find the sum of two array into the third in C-language

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

Program to show present time and date in C-language

Binary searching in C-language

Syntax of C-language