My thought process beginning was to create a string: line[50]="&" and move from there. However, everything I try to get this to work comes out all screwy and resembles nothing close to what is required. Here's an example of what i've tried:
Expand|Select|Wrap|Line Numbers
- /* TRIANGLE PATTERN*/
- #include <stdio.h>
- #include <string.h>
- #define SIZEOF 49
- int main(void)
- {
- /* DECLARATIONS */
- char space = ' ';
- char line[50] = "&";
- char add[2] = "&";
- char adds[2] = " ";
- int counter;
- int loopCount = 0;
- /* DISPLAY FIRST LINE */
- printf("%s", line);
- /* DESIGN & PRINT REST OF THE LINES */
- while(loopCount < 35)
- {
- for(counter = 1; counter < SIZEOF; counter ++)
- {
- if(line[counter] != line[counter - 1])
- {
- strcat(line, add);
- }
- }
- loopCount = loopCount + 1;
- printf("\n%s", line);
- }
- return 0;
- }