Ask Question
16 October, 16:33

34. The variable j starts with the value 10. The variable k starts with the value 2. The variable l starts with the value 4. Store the value of j times k in j. Store the value of k times l in l. Add j and l, and store the result in k. Display the value in k on the screen. program

+3
Answers (1)
  1. 16 October, 18:59
    0
    Following is the program in C+ + language:

    #include / / header file

    using namespace std; / / namespace

    int main () / / main function

    {

    int j=10; / / initialized j to 10

    int k=2; / / initialized k to 2

    int i=4; / / initialized i to 4

    cout<<"old value of j:"<
    j=j*k; //Store the value of k times j in j.

    i=k*i; //Store the value of k times i in i.

    k=j+i; //add the value of j in i and store in k

    cout<<"new value of j:"<
    return 0;

    }

    Output:

    old value of j:10

    old value of i:4

    old value of k:2

    new value of j:20

    new value of i:8

    new value of k:28

    Explanation:

    Following is the explanation of program:

    Declared the variable "j" and initialized 10 to them. Declared the variable "k" and initialized 2 to them. Declared the variable "i" and initialized 4 to them. Print the old value of "j","k" and "i" by using the cout statement. Stored the value of "j" variable in the "k" times of "j" variable. Stored the value of "i" variable in the "k" times of "i" variable. Add the value of "j" variable into "i" variable and store in "k" variable. Finally display the new value of i, j and k variable.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “34. The variable j starts with the value 10. The variable k starts with the value 2. The variable l starts with the value 4. Store the ...” 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