Ask Question
14 May, 06:45

Assume that the following variables have been defined in a program: int x = 10; int y = 20; int z = 30; Write a cout statement that displays the sum of the variables x, y, and z.

+3
Answers (1)
  1. 14 May, 08:49
    0
    The program to this question as follows:

    Program:

    #include / /defining header file

    using namespace std;

    int main () / /defining main method

    {

    int x = 10, y = 20, z = 30; / /defining integer variable and assigning the value

    int sum; //defining integer variable sum

    sum = x+y+z; //adding value, that holds by sum variable

    cout<<"sum: "<
    return 0;

    }

    Output:

    sum: 60

    Explanation:

    Description of the above code as follows:

    In the above code three integer variable "x, y, and z" is declared, that initialized with the value, that is 10, 20, and 30. In the next line, another variable "sum" is declared, that holds the above variable value and add the number. Then the print function "cout" is used, which prints sum variable value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that the following variables have been defined in a program: int x = 10; int y = 20; int z = 30; Write a cout statement that ...” 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