Thursday, March 15, 2012

Displaying a Square of Any Character

Input the side and your desired character and this program will print your desired square out of the character being input.
/*
   title: DisplayingASquareOfAnyCharacter
   author: aeriqusyairi
   date: Jan23 2012
*/
#include<stdio.h>

void displaySquare(char, int);

int main(){
   int side = 0;
   char qwerty;    
   
   printf("Input side:");
   scanf("%d", &side);
   printf("Input character:");
   scanf(" %c", &qwerty);
   
   displaySquare(qwerty, side);
   
   system("pause");
   return 0;
}

void displaySquare(char fillCharacter, int theSide){
   int i, j;
   
   for(i = 1; i <= theSide; i++){
      for(j = 1; j <= theSide; j++){
         printf("%c", fillCharacter);      
      }      
      printf("\n");
   }  
}

No comments:

Post a Comment