Last active
January 23, 2019 19:26
-
-
Save ardrabczyk/631379a8e25d59c01f7922dfdd26be92 to your computer and use it in GitHub Desktop.
Character triangle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
int chars_in_line = 7; | |
char current_letter = 65; /* ASCII A */ | |
int current_chars_in_line = chars_in_line; | |
for(int i = 0; i < chars_in_line; i++) | |
{ | |
printf("%*s", chars_in_line - current_chars_in_line, ""); | |
for(int i = 0; i < current_chars_in_line; i++) | |
{ | |
printf("%c", current_letter++); | |
if (current_letter == 91) /* if we got to Z start from A again */ | |
current_letter = 65; | |
} | |
printf("\n"); | |
current_chars_in_line--; | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: