Demonstrate function arguments - C++ Function

C++ examples for Function:Function Parameter

Description

Demonstrate function arguments

Demo Code

#include <iostream>
using namespace std;
void repchar(char, int);                  //function declaration
int main()/*  w w w .j ava  2s.  c  om*/
{
   repchar('-', 43);
   cout << "Data type   Range" << endl;
   repchar('=', 23);
   cout << "char        -128 to 127" << endl
       << "short       -32,768 to 32,767" << endl
       << "int         System dependent" << endl
       << "double      -2,147,483,648 to 2,147,483,647" << endl;
   repchar('-', 43);
   return 0;
}
// function definition
void repchar(char ch, int n)
{
   for(int j=0; j<n; j++)
      cout << ch;
   cout << endl;
}

Result


Related Tutorials