Monday 31 December 2018

Filled Under:

Find perfect number or not[c programming examples with output]

C programming examples with output

Find perfect number or not
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter any number: ");
scanf("%d",&a);
b=1;
c=0;
while(b<a)
{
           if(a%b==0)
           c=c+b;
           b++;
}
if(c==a)
                printf("%d is a Perfect number",a);
else
                printf("%d is not a Perfect number",a);
getch();
}

Output
Enter any number: 6
6 is a Perfect number
Enter any number:33
33 is not a Perfect number


Check others programming by click here:

0 komentar:

Post a Comment