Question: Hi, I'm trying to write C code that will print the odd abundant numbers between 1 and 5000 and I've written a program for it

Hi, I'm trying to write C code that will print the odd abundant numbers between 1 and 5000 and I've written a program for it but it doesn't work. If you would be able to help me fix it or point out where I went wrong that would be awesome.

# include

int main () { int getSum(int n) int i, n, j, sum = 0; /* print initial statement to give context of program*/ printf(" The odd abundant numbers between 1 and 5000 are: "); scanf("%d", &n); /* first declare a range for the integer i*/ for (i=1; 1<=n; i++); {

/* determine each factor for every integer i*/

for (j = 1; j <= i/2; j++) { if (i % j == 0) { sum = sum + j; } } /* print abundant number alone */ if (sum > i) printf("%d ", n);

sum = 0; } /* determine whether integer i is odd*/ if (i % 2 != 0) { /* print all integers that satisfy these requirements*/ printf("%d", n); } printf(" "); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!