I need to make a program using a module ( two functions, one main and second the calculations)... The program has to tell a perfect numbers between 1 and 1000.
This is what i have now. It gives me an error
LINE 3: error: too few arguments to function `int perfect(int, int, int)'
LINE 15: error: at this point in file
LINE 3: error: too few arguments to function `int perfect(int, int, int)'
LINE 16: error: at this point in file
LINE 3: error: too few arguments to function `int perfect(int, int, int)'
LINE 17: error: at this point in file
So what I'm trying to do is to use the "b" "a" to print in the main function, how can i fix it.
Code:#include<stdio.h> int perfect( int a, int b, int c); /*function prototype*/ /*LINE 3*/ /*function main begins program execution */ int main(void) { printf("This program will tell you the perfect numbers between 1 and 1000:\n"); printf("\n %d Perfect number\n",perfect(b)); /*LINE 15*/ printf("\n Factors of %d are:\n",perfect(b)); /*LINE 16*/ printf("%d\n",perfect(a)); /*LINE 17*/ return 0;/*indicates succeessful termination */ } /*Function perfect definition */ int perfect(int a,int b,int c) { for(b=1;b<=1000;b++) //checks for 1 to 1000 for perfect numbers { a=1; //initialized to check the factor from 1 to n c=0; // to check the sum of factors while(a<b) { if(b%a==0) c=c+a; //if i is a factor of n, i added to s a++; // in all conditions } if(c==b)// if n is a perfect no: { a=1; while(a<b) { if(b%a==0) printf("%d\n",a); a++; } } } return 0; }



LinkBack URL
About LinkBacks


