This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

What am I doing wrong in here? HELP by 10:30 EST 10/27/99


Hey folks... I can't see WHAT i am doing wrong here... any help or
direction would be much appreciated, this one is going down to the
wire...


/****************************************************
*Programmer:  Isaac Petruccelli                     *
*Date: 10/27/99                                     *
*File: perfect.h                                    *
*Description:  This declares the function IsPerfect.*
****************************************************/

extern IsPerfect ( int count );


/****************************************
*Programmer:  Isaac Petruccelli         *
*Date:  10/27/99                        *
*File: main.c                           *
*Description:  This file will call scan *
*a number from the command line         *
*and find all perfect numbers between   *
*1 and that number.                     *
****************************************/

#include <stdlib.h>
#include <stdio.h>
#include "perfect.h"

int main( int argc, char *argv[] ) {
int n;
int count;
int x;
int z;

/*The number from the command line is being stored as an integer type
via the atoi function*/

n=atoi( argv[1]);

for( count=2; count<n; count++){
    IsPerfect ( count );
      if ( z==count )
printf ("%d", count)     ;
}

return (0);
}


/*************************************************************
*Programmer: Isaac Petruccelli                              *
*Date:  10/27/99                                            *
*File: perfect.c                                            *
*Description:  This file uses a for loop, testing all proper*
*divisors up to the number entered from the command line,   *
*starting with the divisor 1.                               *
************************************************************/



int IsPerfect ( int count ){
int i;
int x;
int z;

z=1;

  for ( i=1; i<=n/2; i++ )
     {
      if (count%i==0)
       z=z+i ;

}
return (z);
}


Sent via Deja.com http://www.deja.com/
Before you buy.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]