Hello I'm new here, I try this site when I found the url in the web when I am trying to solve my problem. And I became interested and join.
Hope you can help me with this one:
I have this program:
#include <stdio.h>
main()
{
char input;
int base,a,b,c,d,e;
printf("Input:");
scanf("%c", &input);
printf("Base:");
scanf("%i", &base);
e=base;
for (a=0;a<=base-1;a++)
{
for (d=0;d<=e-a;d++)
printf (" ");
for (b=0;b<=a;b++)
{
printf("%c", input);
}
printf("\n");
}
}
when I run this the result will be a triangle made of a inputed letter.
Input:A
Base:5
A
AA
AAA
AAAA
AAAAA
AAAAAA
Press any key to continue
the problem is I want the input to look like a equilateral triangle but the result is a right triangle.
There's something wrong with the second for statement but until now I don't know how to fix it.
I try changing the condition d<=e-a at the second for statement to d<=50-a but still it doesn't work.
what shall I do...
by the way I'm new with c programming.
(about the posting I am still studying how it works, so for the meantime I just copy and paste my codes... sorry for that :p)