Answer to Question #198907 in C for Nabeel khan

Question #198907

Write a function that accepts a character ch and a number n as arguments. The function then displays an n x n grid filled with ch. Use the function in a program.


1
Expert's answer
2021-05-26T10:38:24-0400
#include <stdio.h>
#include <stddef.h>

void display(char ch, size_t n) {
  for (size_t i = 0; i != n; i++) {
    for (size_t j = 0; j != n; j++) {
      printf("%c", ch);
    }
    printf("\n");
  }
}

int main() {
  display('1', 5);
  display('x', 4);
  display('~', 3);
  display('!', 2);
  display('*', 1);
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS