
April 13th, 2005, 05:25 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 1
Time spent in forums: 56 m 47 sec
Reputation Power: 0
|
|
Top Down Design help
I have a problem with my program. The program is find if a number is perfect for eg 6 is perfect since 1+2+3=6
. Well the program has to determine if a single number passed as perfect. The funtion should return 1 if it is n a 0 if not. Call this program function from the main program for each of the number from 1 to 1000. The main program should print out each of the perfect numbers on seperate lines.
This is wat i got so far
Code:
#include<stdio.h>
#include<conio.h>
int perfect(int num,int perfect1,int perfect2,int perfect3,int perfect4,int perfect5,int perfect6);
void main()
{
int num,prfct;
printf("enter a number: ");
scanf("%d",&num);
prfct=perfect(num);
printf("Perfect is: %d",num);
n1=perfect(perfect1);
n2=perfect(perfect2);
n3=perfect(perfect3);
n4=perfect(perfect4);
n5=perfect(perfect5);
n6=perfect(perfect6);
printf("The perfect numbers are: \n%d\n",n1);
printf("%d\n",n2);
printf("%d\n",n3);
printf("%d\n",n4);
printf("%d\n",n5);
printf("%d\n",n6);
getch();
}
int perfect(int num,int perfect1,int perfect2,int perfect3,int perfect4,int perfect5,int perfect6)
{
int prfctcnt=0;
if(num<=1000 && num<2)
{
num=num-1;
if(num%2==0)
prfctcnt++;
prfctcnt++;
Do u need how to do programming to be a godd electronic engineer
|