Computer Science, asked by gite, 1 year ago

write a functions that prints the character on the screen .write one function called putchar() that accept no argument and print 30 star(*) on the screen on one line..write one function called putchar() that accept one char variable ch on print that the character on the screen fot 30 times .write another function called putchar() that accept two arguments one char variable ch and second int variable t and print the ch on the screen for t times. write a main () function that gets a value from the user to test these function. use function overloading

Answers

Answered by kvnmurty
3
#include <cstdio>
#include <iostream>
#include <string>

#define N 30

void putChar ();
void putChar (char ch) ;
void putChar (char ch, int t) ;


int main (char *argc[], int argv)
{
    int  t; char c;
        cout << "Type in the char to print: " ;
        cin >> c;
       cout << "type in the number of times it is to be printed : ";
       cin >> t;
       cout << "function without parameters: \n";
       putchar ();
       cout << "function with 1 parameter:\n";
       putchar (c);
       cout << "function with 2 parameters;\n";
      putchar (c, t);
}

void putChar ()
{
     int n;
       for (n = 0; n < N ; n++)  fputc ('*', stdout);
       fputc('\n', stdout);
}

void putChar (char c)
{
     int n;
       for (n = 0; n < N ; n++)  fputc (c, stdout);
       fputc('\n', stdout);
}

void purChar (char c, int t)
{
     int n;
       for (n=0; n < t; n++)  fputc(c, stdout);
       fputc('\n', stdout);
}


kvnmurty: click on thanks button above please
Similar questions