Ask Question
18 September, 04:26

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,

+2
Answers (1)
  1. 18 September, 05:41
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers