Here is my code below. If I enter 2 for "How many rows question" and 9 for "How many values to be used question... I get the following result...
Now, the code does what I want but I'm asking how many rows the user wants.
I want the user to be able to enter in how many columns he wants instead of how many rows rows (but I want the same result as before) how would I go about doing it?
Code:
#include <stdio.h>
int func_col(int, int);
int main()
{
int q, a, b, c, x, row, max_value;
printf("How many rows? ");
scanf(" %d", &row);
printf("How many values to be used? ");
scanf(" %d", & max_value);
q = func_col(max_value, row);
for(b=1, c=0; c<row; c++)
{
x=b;
for(a=0; a<q+1; a++)
{
if(x<max_value+1)
printf("%d\t", x);
x+=row;
}
b++;
printf("\n");
}
}
int func_col(int max_value, int row)
{
if(row<5)
return(max_value / row);
else
return((max_value / row)+1);
}