"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Wednesday, March 10, 2010

Write overloaded prototypes of inquote(), a function that displays its argument enclosed in double quotation marks. Write three versions : one for single int value, one for two int values, and one for an array of int values



#include<iostream.h>
#include<conio.h>

/* function 1 */
void inquote(int a)
{
cout<< "\n The value to be printed is \" " << a << " \" ";
}

/* function 2 */
void inquote(double a)
{
cout<< "\n The value to be printed is \" " << a << " \" ";
}

/* function 3 */
void inquote(char a)
{
cout<< "\n The value to be printed is \" " << a << " \" ";
}

void main()
{
int integer;
double dou;
char ch;

/* function 1 is called */
cout<< "\n Enter an integer :";
cin>> integer;
inquote(integer);

/* function 2 is called */
cout<< "\n Enter a decimal value :";
cin>> dou;
inquote(dou);

/* function 3 is called */
cout<< "\n Enter a character :";
cin>> ch;
inquote(ch);

getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.