You're here: Snippet Directory » C/C++ (495)
Language:

Letter output

Language: English
Programming Language: C
Published by: ice_rogue [not registered]
Last Update: 5/15/2006
Views: 137


Description

A prog to take the input of a char and two numbers and output that char in cols and rows. Basic C.

Code

1 /* letter.c Aaron Seidel A prog to take the input of a char 2 and two numbers and output that char in cols and rows */ 3 #include <stdio.h> 4 void out(char ch, int rws, int cls, int spc); 5 int main(void){ 6 int cols, rows, space; 7 char ch; 8 printf("Please enter a charicture, a number, and another number.\n"); 9 scanf("%c %d %d", &ch, &rows, &cols); 10 space=35-(cols/2); 11 out(ch, rows, cols, space); /* Call sub out */ 12 return 0; 13 } 14 15 void out(char ch, int rws, int cls, int spc){ 16 int rows, cols, space; 17 for(rows=rws; rows>0; rows--){ 18 for(space=spc; space>0; space--){ /* Space insertion */ 19 printf(" "); 20 } 21 for(cols=cls; cols>0; cols--){ /* Cols of chars */ 22 printf("%c", ch); 23 } 24 printf("\n"); 25 } 26 return; 27 }

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS