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

Answer :

Answer:

Following is the program in C++ language :

#include <iostream> // 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<<endl<<"old value of i:"<<i<<endl<<"old value of k:"<<k<<endl;

  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:"<<j<<endl<<"new value of i:"<<i<<endl<<"new value of k:"<<k;

   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.