1. Write a C program to Print 1st 30 Perfect numbers starting from 0
main()
{
long i, sum=0, j, count=0;
for(j=1; ;j++)
{
for(i=1; i<=j/2 ; i++)
{
if( j%i = =0)
{
sum += i;
}
}
if(j = =sum)
{
printf("%d ", j);
count + + ;
}
if(count = =30)
{
break;
}
sum=0;
}
getch();
return 0;
}
<< Go to Index Page >>
#include
উত্তরমুছুনmain()
{
long long I, sum=0, J, count=0;
for(J=1;;J++)
{
for(I=1;I<=J/2;I++)
{
if(J%I==0)
{
sum+=I;
}
}
if(J==sum)
{
printf("%lld ", J);
count++;
}
if(count==30)
{
break;
}
sum=0;
}
getch();
return 0;
}
very informative post indeed.. being enrolled in http://www.wiziq.com/course/6314-learn-c-programming-language-low-priced-student-edition was looking for such articles online to assist me.. and your post helped me a lot
উত্তরমুছুন#include
উত্তরমুছুনmain()
{
long i,sum=0,j,count=0;
for(j=1; ;j++)
{
for(i=1;i<=j/2;i++)
{
if(j%i==0)
sum+=i;
}
if(j==sum)
{
printf("\n%d\n",j);
count++;
}
if(count==30)
break;
sum=0;
}
}
উত্তরমুছুন#include
int main()
{
int a, n;
printf("Enter a number: ");
scanf("%d", &n);
for(a = 0; a <= n; a++)
{
if (n == a * a)
{
printf("YES");
return 0;
}
}
printf("NO");
return 0;
}