Hey guys so i produced a multiplication table; however the numbers don't multiply right ex 1 x 1 is not 2 and so on. Not sure where the error for this i want to make it so 1 x 1 = 1; 2 x 1 = 2; 3 x 1 = 3 and so on.
// my header fileCode:// calling program #include <stdio.h> #include <stdlib.h> #include "Myhead.h" #include "legrid.h" int main() { Heading(); ClearTheScreen(); GridBox(3,3,13); PauseTheScreen(); }
Code:void ClearTheScreen() { system("cls"); } void PauseTheScreen() { _settextposition(45,24); _settextcolor(14); system("pause"); } void Carpet(int Color) { int k,m; char Background[2]; Background[0] = 176; Background[1] = '\0'; _settextcolor(Color); for ( k = 0; k < 45; k++) { for ( m = 0; m < 80; m++) { _settextposition(k+1,m+1); _outtext(Background); } } } void Center(int Row,char *Text,int Color) { int k; _settextcolor(Color); k = strlen(Text); k = ( 80 - k ) / 2; _settextposition(Row,k); _outtext(Text); } void Heading() { ClearTheScreen(); Carpet(10); Center(1,"VENTURA COUNTY COMMUNITY COLLEGE DISTRICT",14); Center(2,"Ventura College",14); Center(4,"Programming Fundamentals",13); Center(5,"CS V11 - Fall of 2012",13); Center(7,"Jessica Perez",12); }
Code:// source code void GridBox(int Row,int Col,int Color) { int q,k,m,p; int ASCII; char Number[80]; char UpperLeft[2],UpperRight[2],LowerLeft[2],LowerRight[2]; char Vertical[2],Horizontal[2]; char UpperTee[2],LowerTee[2],LeftTee[2],RightTee[2]; char Cross[2]; _settextcolor(Color); UpperLeft [0] = 218; UpperRight[0] = 191; LowerLeft [0] = 192; LowerRight[0] = 217; Vertical [0] = 179; Horizontal[0] = 196; UpperTee[0] = 194; LowerTee[0] = 193; LeftTee [0] = 195; RightTee[0] = 180; Cross [0] = 197; UpperLeft [1] = '\0'; UpperRight[1] = '\0'; LowerLeft [1] = '\0'; LowerRight[1] = '\0'; Vertical [1] = '\0'; Horizontal[1] = '\0'; UpperTee [1] = '\0'; LowerTee [1] = '\0'; LeftTee [1] = '\0'; RightTee [1] = '\0'; Cross [1] = '\0'; // To print Numbers _settextcolor(14); for (m = 0; m < 5; m++) { for ( k = 0; k < 4; k++) { p = (k+1)*(m+1); itoa(p,Number,10 ); if ( p < 10 ) { _settextposition(4+2*m, 8+2+4*k);//original 21+2+4*k } else if ( p < 100 ) { _settextposition(4+2*m, 8+1*k); } else { _settextposition(4+2*m, 8+0+4*k); } _outtext(Number); } } for ( k = 0; k < 4; k++) { p = k+1; itoa( p,Number,10); if ( p < 10 ) { _settextposition(6+2*k,6); //12 + 2, 19 original } else { _settextposition(6+2*k,7); //12 + 2, 18 original } _outtext(Number); } // CORNERS _settextposition(Row,Col); _outtext(UpperLeft); _settextposition(Row,Col+(3+1)*5); _outtext(UpperRight); _settextposition(Row+(1+1)*5,Col); _outtext(LowerLeft); _settextposition(Row+(1+1)*5,Col+(3+1)*5); _outtext(LowerRight); // Horizontal Lines for ( q = 0; q < 5 + 1 ; q++) { for ( k = 0; k < 5 ; k++) { for ( m = 0; m < 3 ; m++) { _settextposition(Row+(1+1)*q,(Col+1)+(3+1)*k+m); _outtext(Horizontal); } } } // Vertical Lines for ( q = 0; q < 5 + 1 ; q++) { for ( k = 0; k < 5 ; k++) { for ( m = 0; m < 1 ; m++) { _settextposition((Row+1)+(1+1)*k+m,Col+(3+1)*q); _outtext(Vertical); } } } // Upper & LowerTee's for ( k = 0; k < 5 - 1 ; k++) { _settextposition(Row,Col+(3+1)*k+3+1); _outtext(UpperTee); _settextposition(Row+(1+1)*5,Col+(3+1)*k+3+1); _outtext(LowerTee); } // Right & Left Tee's for ( k = 0; k < 5 - 1 ; k++) { _settextposition(Row+(1+1)*k+1+1,Col); _outtext(LeftTee); _settextposition(Row+(1+1)*k+1+1,Col+(3+1)*5); _outtext(RightTee); } // Crosses for ( k = 0; k < 5 - 1 ; k++) { for ( m = 0; m < 5 - 1 ; m++) { _settextposition(Row+(1+1)*k+1+1,Col+(3+1)*m+3+1); _outtext(Cross); } } }



LinkBack URL
About LinkBacks



