C++ Function Parameter

Description

C++ Function Parameter

#include <iostream>
using namespace std;
void repchar(char, int);                  //function declaration
int main()/*from   ww w. j  a  va2 s . c  o  m*/
{
   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;
}



PreviousNext

Related