A function to print a character number of times and in number of lines My task was:

Write a function that takes three arguments: a character and two integers. The
character is to be printed. The first integer specifies the number of times that the
character is to be printed on a line, and the second integer specifies the number
of lines that are to be printed. Write a program that makes use of this function.

And my code is: (i know i did not add different scenarios like if the first char is number etc, but please let me know if it looks ok)

#include &lt;stdio.h&gt;
void printing_char (char ch, int numberOfChars, int numberOfLines);

int main (void)
{
    char userChar;
    int lines,times;
    printf ("please enter a character, number of times in a line, and number of lines:\n");
    while ((scanf ("%c%d%d", &amp;userChar, &amp;times, &amp;lines)) == 3)
    {
        printing_char (userChar, times, lines);
    }
    return 0;
}

void printing_char (char ch, int numberOfChars, int numberOfLines)
{
    int x;
    int y = 0;

    while (++y &lt;= numberOfLines)
    {
            for (x = 0; x&lt;numberOfChars; x++)
            {
                printf ("%c", ch);
            }
            printf ("\n");
    }
}
Only a couple of things:


int lines,times; - one declaration per line, please!
scanf("%c%d%d", &amp;userChar, &amp;times, &amp;lines) - where does one number end and the next start?. You need to include some terminating characters, such as ,

printf("please enter a character, number of times in a line, and number of lines, separated by a comma:\n");
while ((scanf("%c,%d,%d", &amp;userChar, &amp;times, &amp;lines)) == 3)

An expression such as while (++y &lt;= numberOfLines) is confusing, what value does y have at each step? It'd be better to rewrite this as a for loop

for ( y = 0; y &lt; numberOfLines; y++ )