Write a C++ Program to demonstrate Passing String to a user defined function.
Program Code:
Program Code:
#include <iostream>
using namespace std;
// display() function declaration
void display(char str[]);
// main() function definition
int main()
{
char name[30];
cout << "Enter your string: ";
cin.get(name, 30);
// user defined function display() calling
display(name);
return 0;
}
// user defined function display() definition
void display(char str[])
{
cout << "Your entered string is : " ;
cout<< str;
cout<<endl;
}
The program output is tested on www.jdoodle.com
Output:
Enter your string: Mukesh Rajput
Your entered string is : Mukesh Rajput
Thanks
Mukesh Rajput
Post A Comment:
0 comments: