Hi, everyone from C Board. I'm very new at C, and I'm absolutely stuck here with loops within loops in this program I have to write.

I'll be honest and say that this is an assignment problem, but I don't expect anyone to help me write it, I'm just dumbfounded as to the things I need to do to it to have it work. I have the plan designed for it, but all these loopings is getting me nowhere.

1) what i want to do is allow the user to input a number which will be divided into 3 sizes that the user chooses. eg. the number is 500 and we can make chunks of 20,10, and 30 from it with different combinations. (20 x 20 + 10 x 10 + 0 x 30 for example as long as it doesn't go over the max which is 500)

- after they enter the numbers and it satisfies the if statement in blue, i want to initialize counters for 3 integers i,j,k starting at 0, which will count from 0 to maxlength+1 while a*i+b*j+c*k<=maxlength and then the output will be a list of all the combinations that can be generated from those 3 numbers.

Here's my program as of now:

Code:

#include <stdio.h>
#include <math.h>
#define maxlength 100
int main(void)
{
int total, a, b, c;
int i,j,k;
printf("...\n");
scanf("%d",&total);
{ if (total=<maxlength)
printf("Enter 3 numbers\n", total);
scanf("%d%d%d", &a,&b,&c);
{if ((a>=0) && (b>=0) && (c>=0) && (a+b+c<=maxlength))
{
for (i=0;i<maxlength+1;i++)
for (j=0;j<maxlength+1;j++)
for (k=0;k<maxlength+1;k++)
do{
a*i+b*j+c*k
while (a*i+b*j+c*k<=maxlength){
printf ("%d x %d + %d x %d + %d x %d\n", i+1, j+1, k+1, a,b,c);
}
}
else {
printf("Enter 3 valid numbers again");
}
else {
printf("Please enter a length between 0 and 100 and try again");
}
}
}
return (0);
}

I don't know how to continue especially the part with the for loop which seems to be a mess. I'm hoping you guys can help me resolve this problem. I'd appreciate it a lot.