Hi guys, I'm having trouble with the following code: first problem is, i'm really not very good at mathematics and the equation to represent the spaces eludes me.
What am i doing wrong please. I've visited this link where salem was helping another individual and it clarified a few things in terms of the structure but i'm still a little mystified at the output i get. Compile it and you see the weird structure.
thank you.
Code:
/* pyramid.c output: *
***
*****
*******
*********
*/
#include <stdio.h>
int main(void){
int r,c,s, ht=5;
for (r = 1; r <=ht; r++){ //number of rows
for (s = 1; s <=(ht-(r/2)); s++) // determine spaces
printf(" ");
for (c = 1; c <=r; c++)//determine num of charaters to place
printf("%c", '*');
printf("\n");
}
getchar();
return 0;
}