In C++
------------------------------------------
All functions take no parameters as input and return nothing.
Create a function for each of the following:
CODE IN C++:
#include <iostream>
using namespace std;
//method to take string from the user and displaying it
void display(){
string str;
cout << "Enter the text:";
cin>>str;
cout<<"Your text is:"<<str+" "<<endl;
}
//method to take two integers from the user and add them
void add(){
int a,b;
cout<<"Enter two numbers:";
cin>>a>>b;
cout<<"The sum of your numbers
is:"<<a+b<<endl;
}
int main()
{
//calling the methods
display();
add();
return 0;
}
OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.