Hi I have written a small program in which I am trying to assign values to variables a and b (1000-5000 with increment 1000 and 100-500 with increment of 100) dependent to the counter interval of 20. So that on each counter interval all possible combinations are assigned to these two variable (a and b). I apologize for my English and hope that my description makes some sense to the reader.
The program works as expected! But I want to make it look simpler and get rid of if repetitions. I have tried a while and for loop but due to lack of experience I could not simplify it. I hope some people can show me the way how to do it. And get my coding level further.
Thank you
Here is the code:
insert
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int xinterval = 20;
int y=5;
int x=5;
int count;
int states = x*y;
int a=0;
int b=0;
for(count=0;count<(xinterval*states);count++)
{
printf("%i\t%i\t%i\n", count,a,b);
if(count>0){a=1000;b=100;}
if(count>20){a=1000;b=200;}
if(count>40){a=1000;b=300;}
if(count>60){a=1000;b=400;}
if(count>80){a=1000;b=500;}
if(count>100){a=2000;b=100;}
if(count>120){a=2000;b=200;}
if(count>140){a=2000;b=300;}
if(count>160){a=2000;b=400;}
if(count>180){a=2000;b=500;}
if(count>200){a=3000;b=100;}
if(count>220){a=3000;b=200;}
if(count>240){a=3000;b=300;}
if(count>260){a=3000;b=400;}
if(count>280){a=3000;b=500;}
if(count>300){a=4000;b=100;}
if(count>320){a=4000;b=200;}
if(count>340){a=4000;b=300;}
if(count>360){a=4000;b=400;}
if(count>380){a=4000;b=500;}
if(count>400){a=5000;b=100;}
if(count>420){a=5000;b=200;}
if(count>440){a=5000;b=300;}
if(count>460){a=5000;b=400;}
if(count>480){a=5000;b=500;}
}
return 0;
}