First off you must remember indentation. It is so important.
Code:
#include < stdio.h >
int main ()
{
int N, a, f, sum, prod;
printf (" Enter a positive integer greater than one:\n");
scanf ("%d", &N);
if ( N < 2)
{
printf (" Please enter a positive integer greater than one:\n");
}
else
{
for ( a >= 1 && a =< N; N % a == 0; a++)
f= N % a;
printf (" Here is the list of the positive factors of %d : %d ", N, f);
}
for ( sum = 0; sum = sum + f, sum++ )
{
printf ("The sum of the positive factors of %d is %d .\n", N, sum);
}
do
{
prod = 1;
prod = prod * f;
}while ( prod <= (2^31-1));
printf ( "The product of the positive factors of %d is %d.\n", N, prod);
return 0;
}
Ok now to tear it apart
Code:
#include < stdio.h >
my compiler yelled at me for the spaces. needs to be <stdio.h>
Code:
printf (" Enter a positive integer greater than one:\n");
scanf ("%d", &N);
if ( N < 2)
{
printf (" Please enter a positive integer greater than one:\n");
}
else
{
for ( a >= 1 && a =< N; N % a == 0; a++)
{
f= N % a;
}
printf (" Here is the list of the positive factors of %d : %d ", N, f);
}
Put the scanf and the if statement in a do while loop. That way you can force the user to input a valid number. Take the stuff in the else and put it after the loop since you will then know the number is valid.
Code:
for ( a >= 1 && a =< N; N % a == 0; a++)
This is horribily wrong. The first part of the for loop is assigning a value and is not a conditional statement.
Code:
for ( a >= 1 && a =< N; N % a == 0; a++)
{
f= N % a;
}
The for loop is assigning the reminder of the integer divison to f, but it does nothing with it, why?
Code:
for ( sum = 0; sum = sum + f, sum++ )
while this might be syntaxally correct it will give you an infinate loop. How can sum ever equal itself plus another number? Remember it reevaulates the left and right value of the conditional statement on every iteration.
Code:
do
{
prod = 1;
prod = prod * f;
}while ( prod <= (2^31-1));
Why are you making the program do unnessary math? Since (2^31)-1 is a constent why not just put the value in yourself? (2147483647)
One thing I forgot to add: Try compiling your program and running it, lots of answers can be found that way.