Ask Question
15 October, 13:02

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,

+3
Answers (1)
  1. 15 October, 13:22
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers