Ask Question
16 October, 10:59

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.

+4
Answers (1)
  1. 16 October, 11:04
    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?
Find 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 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