#include<stdio.h>
int main()
{
int n, i, sum = 0;
printf("Enter any number to check whether it is Perfect or Not\n");
scanf("%d",&n);
for(i = 1; i < = n / 2; i++)
{
if(n % i = = 0)
{
sum = sum + i;
}
}
if(sum = = n)
{
printf("Given number is A Perfect Number");
}
else
{
printf("Given number is Not A Perfect Number");
}
return 0;
}
INPUT 1:
Enter any number to check whether it is Perfect or Not
6
OUTPUT 1:
Given number is A Perfect Number
INPUT 2:
Enter any number to check whether it is Perfect or Not
7
OUTPUT 2:
Given number is Not A Perfect Number
Monday, December 17, 2018
Home
/
C Programming
/
Simple Programs
/
WAP in C to check whether a given number is A Perfect Number or Not
WAP in C to check whether a given number is A Perfect Number or Not
Topics
# C Programming
# Simple Programs
About HindiKisseKahaniyaan
Easy Programming All is a free blogger to the students who wants to learn programming in C, HTML, CSS, Bootstrap, Web Designing from home. The students can learn programming free of cost at their home. We provide best logics about any program. If you want to ask any logic of any program you can comment to us in comment box.
Simple Programs
Labels:
C Programming,
Simple Programs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment