draw a rectangular grid having 10 rows and 10 columns

Y

yugas

how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.
 
W

Walter Roberson

how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.

% the below is deliberately not coded in C
Let top be '|' + repeat '-|' x rows/2 + newline
Let mid be '|' + repeat ' |' x rows/2 + newline
Let grid be repeat {top + mid} x columns/2 + top
Output grid
Turn paper sideways
 
J

Joe Schmo'

(e-mail address removed)-cnrc.gc.ca (Walter Roberson) wrote in @canopus.cc.umanitoba.ca:
% the below is deliberately not coded in C
Let top be '|' + repeat '-|' x rows/2 + newline
Let mid be '|' + repeat ' |' x rows/2 + newline
Let grid be repeat {top + mid} x columns/2 + top
Output grid
Turn paper sideways

The original poster should read about C program flow control before
attempting this.
 
R

Richard Bos

yugas said:
how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.

how to do homework. please do homework self.

Richard
 
A

Army1987

how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.
#include <stdio.h>
int main(void)
{
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
puts("| | | | | | | | | | |");
puts("+--+--+--+--+--+--+--+--+--+--+");
return 0;
}
 
E

Eric Sosman

yugas wrote On 09/05/07 20:27,:
how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.

#define s exit('+')
#define d exit('-')
#define n exit('\n')
#define p exit('|')
#define m exit(' ')
#define r main(g,f);break
#define v case
int main(int g,char**f){extern int putchar(int);int(*exit)
(int)=putchar;switch(-g--){v 97:v 99:v 98:return 0;default
:r;v 12:v 2:v 22:v 29:v 39:v 49:v 56:v 59:v 66:v 76:v 86:v
93:d,d,s,d,d,s,d,r;v 32:v 96:d,d,s,d,d,s,n,r;v 5:v 69:d,d,
s,n,p,m,m,r;v 13:v 20:v 3:v 30:v 40:v 47:v 50:v 57:v 67:v
77:v 84:v 94:d,s,d,d,s,d,d,r;v 23:v 87:d,s,d,d,s,n,p,r;v 60
:d,s,n,p,m,m,p,r;v 17:v 24:v 27:v 34:v 44:v 54:v 61:v 7:v
71:v 81:v 88:v 91:m,m,p,m,m,p,m,r;v 64:m,m,p,m,m,p,n,r;v
37:m,m,p,n,s,d,d,r;v 15:v 18:v 25:v 35:v 45:v 52:v 62:v 72
:v 79:v 8:v 82:v 89:m,p,m,m,p,m,m,r;v 55:m,p,m,m,p,n,s,r;v
28:v 92:m,p,n,s,d,d,s,r;v 42:n,p,m,m,p,m,m,r;v 10:v 74:n,s,
d,d,s,d,d,r;v 16:v 26:v 33:v 36:v 43:v 53:v 6:v 63:v 70:v 73
:v 80:v 9:v 90:p,m,m,p,m,m,p,r;v 46:p,m,m,p,n,s,d,r;v 19:v
83:p,n,s,d,d,s,d,r;v 1:v 11:v 21:v 31:v 38:v 4:v 41:v 48:v
58:v 65:v 68:v 75:v 85:v 95:s,d,d,s,d,d,s,r;v 14:v 78:s,d,d
,s,n,p,m,r;v 51:s,n,p,m,m,p,m,r;}return 0;}
 
U

user923005

how to write a c program to draw a rectangular grid having 10 rows and
10 columns. please help me.

#include<stdio.h>
char q0??(32767??); void q1(int q2,int q3)??<int q4,q5; for(q4=0;
q4<q2;
q4++)??<putchar('+'); for(q5=0; q5<q3; q5++)putchar('-'); ??
putchar('+');
putchar('\n'); ??>void q6(int q2,int q3)??<int q4,q5; for(q4=0;
q4<q2; q4
++)??<putchar('|'); for(q5=0; q5<q3; q5++)putchar(' '); ??
putchar('|');
putchar('\n'); ??>int main(void)??<q7:puts("\105\156\164\145"
"\162\40\164\150\145\40\147\162\151\144\40\150\145\151\147\150\164\72"
); fflush(stdout); if(fgets(q0,sizeof q0,stdin))??<int q8=atoi(q0);
puts(
"\105\156\164\145\162\40\164\150\145\40\147\162\151\144\40"
"\167\151\144\164\150\72"); fflush(stdout); if(fgets(q0,sizeof
q0,stdin))
??<int q9=atoi(q0);
puts("\105\156\164\145\162\40\164\150\145\40\147\162\151"
"\144\40\167\151\144\164\150\40\163\143\141\154\145\72"
); fflush(stdout); if(fgets(q0,sizeof q0,stdin))??<int q10=atoi(q0);
puts
("\105\156\164\145\162\40\164\150\145\40\147\162\
\151\144\40\150\145\151\147\150\164\40\163\143\141\154\145\72");
fflush
(stdout); if(fgets(q0,sizeof q0,stdin))??<int q11=atoi(q0); int q12;
for(
q12=0; q12<q8; q12++)??<int q13; q1(q9,q10); for(q13=0; q13<q11; q13+
+)q6(q9
??<goto q7; ??>??>else??<goto q7; ??>putchar('\n'); return 0; ??>
 
U

user923005

#include<stdio.h>
char q0??(32767??); void q1(int q2,int q3)??<int q4,q5; for(q4=0;
q4<q2;
q4++)??<putchar('+'); for(q5=0; q5<q3; q5++)putchar('-'); ??>putchar('+');

putchar('\n'); ??>void q6(int q2,int q3)??<int q4,q5; for(q4=0;
q4<q2; q4
++)??<putchar('|'); for(q5=0; q5<q3; q5++)putchar(' '); ??>putchar('|');

putchar('\n'); ??>int main(void)??<q7:puts("\105\156\164\145"
"\162\40\164\150\145\40\147\162\151\144\40\150\145\151\147\150\164\72"
); fflush(stdout); if(fgets(q0,sizeof q0,stdin))??<int q8=atoi(q0);
puts(
"\105\156\164\145\162\40\164\150\145\40\147\162\151\144\40"
"\167\151\144\164\150\72"); fflush(stdout); if(fgets(q0,sizeof
q0,stdin))
??<int q9=atoi(q0);
puts("\105\156\164\145\162\40\164\150\145\40\147\162\151"
"\144\40\167\151\144\164\150\40\163\143\141\154\145\72"
); fflush(stdout); if(fgets(q0,sizeof q0,stdin))??<int q10=atoi(q0);
puts
("\105\156\164\145\162\40\164\150\145\40\147\162\
\151\144\40\150\145\151\147\150\164\40\163\143\141\154\145\72");
fflush
(stdout); if(fgets(q0,sizeof q0,stdin))??<int q11=atoi(q0); int q12;
for(
q12=0; q12<q8; q12++)??<int q13; q1(q9,q10); for(q13=0; q13<q11; q13+
+)q6(q9
,q10); ??>q1(q9,q10); ??>else??<goto q7; ??>??>else??<goto q7; ??>??>else

??<goto q7; ??>??>else??<goto q7; ??>putchar('\n'); return 0; ??>


Hopefully, this one won't be destroyed by word wrap:

#include<stdio.h>
char q0??(32767??);
void q1(int q2,int q3)??<int q4,q5;
for(q4=0;
q4<q2;

q4++)??<putchar('+');
for(q5=0;
q5<q3;
q5++)putchar('-');
??>putchar('+');

putchar('\n');
??>void q6(int q2,int q3)??<int q4,q5;
for(q4=0;
q4<q2;
q4
++)??<putchar('|');
for(q5=0;
q5<q3;
q5++)putchar(' ');
??>putchar('|');

putchar('\n');
??>int main(void)??<q7:puts("\105\156\164\145\162\40\164\150"
"\145\40\147\162\151\144\40\150\145\151\147\150\164\72"
);
fflush(stdout);
if(fgets(q0,sizeof q0,stdin))??<int q8=atoi(q0);
puts(
"\105\156\164\145\162\40\164\150\145\40\147\162\151\144\40"
"\167\151\144\164\150\72");
fflush(stdout);
if(fgets(q0,sizeof q0,stdin))
??<int q9=atoi(q0);
puts("\105\156\164\145\162\40\164\150\145\40\147\162\151"
"\144\40\167\151\144\164\150\40\163\143\141\154\145\72"
);
fflush(stdout);
if(fgets(q0,sizeof q0,stdin))??<int q10=atoi(q0);
puts
("\105\156\164\145\162\40\164\150\145\40\147\162\151\144\40"
"\150\145\151\147\150\164\40\163\143\141\154\145\72");
fflush
(stdout);
if(fgets(q0,sizeof q0,stdin))??<int q11=atoi(q0);
int q12;
for(
q12=0;
q12<q8;
q12++)??<int q13;
q1(q9,q10);
for(q13=0;
q13<q11;
q13++)q6(q9
,q10);
??>q1(q9,q10);
??>else??<goto q7;
??>??>else??<goto q7;
??>??>else
??<goto q7;
??>??>else??<goto q7;
??>putchar('\n');
return 0;
??>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top