Ask Question
5 March, 08:53

Practice problems on functions. Write C function (s) to carry out the specified tasks. For each problem, also write the suggested application program (s) that apply the function. (1) Write a function multiPrint (int n, char c) that prints n copies of a character c.

+1
Answers (1)
  1. 5 March, 11:41
    0
    Function:

    int fun (int n, char c) / / function definition with a two argument in which variable n is a integer type and variable c is a character type.

    {

    while (n>0) / / while loop

    {

    printf ("%c", c); / / print statement for character

    n--; / / decrease statement to false the loop.

    }

    return 0; / /return statement.

    }

    output:

    When the user pass n=5 and c='a', it will prints 5 times 'a' character. When the user passes n=10 and c='t', it will print 10 times 't' character.

    Explanation:

    Firstly we declare a function of two arguments in which variable n is an integer type and variable c is a character type. Then in the function body, we use while loop from n times iteration because question demands to print n time any character. Then in the loop body, we use a print statement to print a character and a decrease statement to false the loop after a finite iteration.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Practice problems on functions. Write C function (s) to carry out the specified tasks. For each problem, also write the suggested ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers