Ask Question
22 August, 12:52

1.7 Code Practice: Question 1

Write a program that uses two input statements to get two words as input. Then, print the words on one line separated by a space,

+1
Answers (1)
  1. 22 August, 14:02
    0
    Code in C++

    Explanation:

    #include / /for input and output

    #include

    using namespace std;

    int main ()

    {

    string firstStatement;

    string secondStatement;

    cout<<"Enter your first statement : ";

    getline (cin, firstStatement);

    cout<<"Enter your second statement : ";

    getline (cin, secondStatement);

    cout<
    return 0;

    }

    Code Explanation

    To get string as an input, program should include string package.

    Firstly we need to declare 2 strings for 2 statements. then by using getline method exists in string package, we can get string from user input.

    Then to show the concatinated output of both statement we can use cout phrase.

    Output

    Case 1:

    Enter your first statement : Hello

    Enter your second statement : World

    Hello World

    Case 2:

    Enter your first statement : Today is

    Enter your second statement : Sunday

    Today is Sunday
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “1.7 Code Practice: Question 1 Write a program that uses two input statements to get two words as input. Then, print the words on one line ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers