Question

4. Include a function that adds two strings to make a third string. Write a program to do the following tasks: i. Create unin

in c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;

string concatStrings(string str1,string str2);
int main()
{
string str1,str2,str3;
cout<<"Enter String#1:";
getline(cin,str1);
cout<<"Enter String#2:";
getline(cin,str2);
str3=concatStrings(str1,str2);
cout<<"String#3:"<<str3<<endl;

return 0;
}
string concatStrings(string str1,string str2)
{
   return str1+" "+str2;
}

_________________________

Output:

C:Program Files (x86) Dev-CpplMinGW64\bin StringConcatinateUsingFunction.exe Enter String#1 :Hello Enter String#2:World! Stri


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
in c++ 4. Include a function that adds two strings to make a third string. Write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please teach me how to use function interface by java ● Write a functional interface StringOperator...

    Please teach me how to use function interface by java ● Write a functional interface StringOperator with the method performOperation that takes two references to String objects as parameters. ● In a driver program, use lambda expressions to create two different objects that implement the StringOperator interface. ○ One of them concatenates the two Strings, returning the new String ○ One of them sets the first String to all uppercase and the second String to all lowercase and then concatenates...

  • 1) Given the following “BasicAccount” class #include <iostream> #include <string> class BasicAccount {    private:      ...

    1) Given the following “BasicAccount” class #include <iostream> #include <string> class BasicAccount {    private:       std::string m_username ;       std::string m_password ;    public:       BasicAccount(std::string username, std::string password)       {          m_username = username ;          m_password = password ;       }               virtual std::string toString()       {          return "USERNAME(" + m_username + ") PASSWORD(" + m_password + ")" ;       }          std::string getUserName()       {          return m_username ;       }      virtual...

  • Write a function addStrings(string1, string2) that takes in two decimals as strings and returns a string...

    Write a function addStrings(string1, string2) that takes in two decimals as strings and returns a string of their sum. *Simply converting strings to numbers and adding them together isn’t acceptable.* The program must be able to handle large decimals. Be sure to touch on these when solving for the solution: Pad the right side Pad the left side Make sure string is same length by putting 0’s where it was missing (be careful w/ decimal points) Make sure to remove...

  • C++, use the skeleton code to make a program of the following

    c++, use the skeleton code to make a program of the following include <iostream> tinclude <string> using namespace std; class car public: //define your functions here, at least 5 private: string name; int mpg; double price int horsepower; // feel free to add more atributes int main() // create you objects, call your functions // define member functions here For this lab, write a program that does the following: Creates a class based on the car skeleton code (you may...

  • C programming 1 String Merging Write a program that reads two strings s1 and s2 from...

    C programming 1 String Merging Write a program that reads two strings s1 and s2 from the keyboard and merges them to a string s3. Strings s1 and s2 are statically allocated whereas s3 is dynamically allocated to fit exactly s1 and s2. The two original strings are no longer than 100 characters long. Use the following function to merge the two strings. char *stringMerge(char s1[], char s2 []); Example: Enter the first string: Hello world Enter the first string:...

  • Write a program thet uses the function strcmp() to compare two strings input by the user....

    Write a program thet uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less then, equal to, or greater then the second string 7. Write a program thet uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less then, equal to, or greater then the second string

  • Write a c# console program called “ArrayOfThings” where you create a class called Staff with private...

    Write a c# console program called “ArrayOfThings” where you create a class called Staff with private fields for StaffID and StaffName. Create Properties that can write data and retrieve data from these private fields. Create a Staff array that can hold up to ten Staff objects. Create ten objects using a for loop that automatically creates a new (empty) Staff object at each iteration of the loop and adds that object into the Staff array. Write data into the first...

  • must be done in C Write a program that uses function strncmp to compare two strings...

    must be done in C Write a program that uses function strncmp to compare two strings input by the user. The program should input the number of characters to be compared, then display whether the first string is less than, equal to, or greater than the second string.

  • Prompt the user to enter two character strings. The program will then create a new string...

    Prompt the user to enter two character strings. The program will then create a new string which has the string that appears second, alphabetically, appended to the end of the string that shows up first alphabetically. Use a dash (-') to separate the two strings. You must implement the function string appendStrings(string, string), where the return value is the combined string. Display the newly created string. Your program must be able to handle both uppercase and lowercase characters. You are...

  • Write a function that takes two arguments, both strings. Print "YES" if the second string argument...

    Write a function that takes two arguments, both strings. Print "YES" if the second string argument contains only characters found in the first string argument. Print "NO" if the second string argument contains characters not in the first. Here are some sample calls. In your program, call the function 3 times with the same arguments shown below. makeStr("hello", "") makeStr("hello", "olleloheloeloheloel") makeStr("hello", "olleloheloteloheloel") # YES # YES # NO

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT