Usually, the start is the part of the program that we want the student to show us. That way we help them over the problem, and we know exactly what it is, by seeing the code they post up.
But here's a small start for you:
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_Y 41
#define MAX_X 41
void printIt(char grid[MAX_Y][MAX_X],int, int, int, int);
int main(void) {
/*//highX highY would be limits X and Y where they are smaller
than MAX_X or MAX_Y, respectively. Not used here.
*/
int r,c,width=10,height=5,highX=21,highY=21;
char grid[MAX_Y][MAX_X]={' '};
//One way to set up the grid with initial values.
for(r=0;r<=highY;r++) {
for(c=0;c<=highX-1;c++) {
if(r%height==0 && c%width==0) {
grid[r][c]='+';
}else if(r%height==0) {
grid[r][c]='-';
}else if(c%width==0) {
grid[r][c]='|';
}
}
}
printIt(grid, width, height, highX, highY); //check that your inital grid is OK
//add the graph char's here, and call
//printIt again, to display final grid.
return 0;
}
void printIt(char grid[MAX_Y][MAX_X],int width, int height, int highX, int highY) {
int r, c;
for(r=0;r<highY;r++) {
if(r%height==0)
printf("%2d ",highY-1-r);
else
printf(" ");
for(c=0;c<=highX;c++) {
putchar(grid[r][c]);
}
putchar('\n');
}
printf(" ");
for(c=0;c<=highX;c++) {
if(c%width==0 && c>0) {
printf("%2d",c);
c++;
}else
putchar(' ');
}
}
That should help you get started.