Answer to Question #198330 in C for Ayesha

Question #198330

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-25T05:41:48-0400
#include<stdio.h>
#include<stdlib.h>
void grid(char ch, int n);
int main()
{
    int n;
    char ch;
    printf("Enter a char : ");
    scanf("%c",&ch);
    printf("Enter a number : ");
    scanf("%d",&n);
    grid(ch,n);
}
void grid(char ch, int n)
{
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            printf("%c ",ch);
        }
        printf("\n");
    }
}

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