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...

  • Java Programming Write a function which is passed two strings. The function creates a new string...

    Java Programming Write a function which is passed two strings. The function creates a new string from two original strings by copying one character from each in turn until all characters have been copied. No use of scanner, hashmap, or exceptions please.

  • 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...

  • (Longest common prefix, C-string, loop, char comparison) Write the prefix function to find the longest prefix...

    (Longest common prefix, C-string, loop, char comparison) Write the prefix function to find the longest prefix of two strings using C-strings with the following header: void prefix( const char s1[ ], const char s2[ ], char commonPrefix[ ]) Write a test program that prompts the user to enter two C-strings and displays their common prefix. Sample run :- String 1: Programming is fun String 2: Program logic The common prefix is program.

  • Write a program in C to check whether two given strings are an anagram. From the...

    Write a program in C to check whether two given strings are an anagram. From the following prototype, statement create a function that determines whether two strings are anagrams. Test Data: Input the first String: spare Input the second String: pears Expected output: spare and pears are an anagram updated

  • 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...

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