Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program that includes a function called lobster() that accepts three a

ID: 3922911 • Letter: W

Question

Write a C program that includes a function called lobster() that accepts three arguments: a character and two integers. The character argument is the character to be printed by lobster(). The second argument is the number of times that the character will be printed on a row. The third argument is the number of rows to be printed. Call your function from within your program in order to demonstrate that it works (use 'z', 3, 5 as parameters). Comment your code, make sure it looks professional, and use meaningful variable names.

Explanation / Answer

include<stdio.h>
void lobster(char,int,int); //function prototype
int main()
{
        int row,col; //declare rows and columns in integer
        char ch;

        printf("Enter the character to be printed :"); //read character
        scanf("%c",&ch);
        printf("Enter the number of rows :"); //read rows
        scanf("%d",&row);
        printf("Enter the number of columns :"); //read columns
        scanf("%d",&col);

        lobster(ch,row,col); //call lobster function

        return 0;
}
void lobster(char cha,int ro,int co)
{
        for(int i=0;i<co;i++) //number of columns
        {
                for(int j=0;j<ro;j++) //number of rows
                {
                        printf("%c ",cha);
                }
                printf(" "); // goto new line after completing each row
        }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote