Created
December 11, 2019 18:35
-
-
Save NotaPhysicist/38a424f9b8c1026a308cb5a0a925495d to your computer and use it in GitHub Desktop.
Playing around with printing a grid of characters using for loops and putchar() and passing arguments in functions.
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
/** | |
* putchar.c -- playing around with printng a grid of characters using | |
* for loops and putchar and passing arguments in functions | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
void printchar(char ch, int rows, int cols); | |
int main(void) | |
{ | |
char ch = '+'; | |
int rows = 5; | |
int cols = 5; | |
printchar(ch, rows, cols); | |
return EXIT_SUCCESS; | |
} | |
void printchar(char ch, int rows, int cols) | |
{ | |
int i, j; | |
for (i = 0; i < rows; i++) | |
{ | |
for (j = 0; j < cols; j++) | |
{ | |
putchar(ch); | |
} | |
putchar('\n'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment