thanks for response..
The purpose of my code is to print the capitol building, increase each tier by two each time i.e 1,3,5,7,9.
For each tier i would like to have two lines i.e
Code:
Tier 1 = T
|
Tier 2 = TTT
|||
Tier 3 = TTTTT
|||||
value: 18
here is my code so far. the only thing stopping me is the way i am printing the tiers. i am trying to achieve a total of 6.
Code:
#include <stdio.h>
int drawImages(int, char);
int main( ) {
int rv;
rv = drawImages(6, 'c');
printf("%d\n", rv);
return 0;
}
int drawImages(int rows, char type) {
int i, j, k, letter, spaces, rv = 0;
letter = 1;
spaces = rows-1;
if(type == 'c') {
if(rows >=1) {
for(i=0; i<rows; i++) {
for(j=0; j < spaces; j++) {
printf(" ");
}
for(k=0; k < letter; k++) {
if(i%2==0){
printf("T");
rv++;
}
else{
printf("|");
rv++;
}
}
spaces--;
letter = letter + 2;
printf("\n");
}
}
else {
printf("Sorry, cannot draw image...\n");
rv = -1;
}
}
return rv;
}
This code prints out
Code:
T
|||
TTTTT
|||||||
TTTTTTTTT
|||||||||||
Value:36
However, I am trying to achieve this..
Code:
T
|
TTT
|||
TTTTT
|||||
TTTTTTT
|||||||
TTTTTTTTT
|||||||||
TTTTTTTTTTT *** note here, it does not print the second line at the base***
Value:61