Posts Tagged ‘integer variables’
Write a statement that declares and initializes two integer variables.
LANGUAGE: C++ CHALLENGE: Write a statement that declares and initializes two integer variables. Call the first one age and initialize it to 15, and call the second one weight and initialize it to 90.
Read MoreWrite some code that swaps their values. Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner.
LANGUAGE: C++ CHALLENGE: Given two int variables, firstPlaceWinner and secondPlaceWinner, write some code that swaps their values. Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner.
Read Morewrite some code that swaps the values in i and j. Use temp to hold the value of i and then assign j’s value to i.
LANGUAGE: C++ CHALLENGE: Given three already declared int variables, i, j, and temp, write some code that swaps the values in i and j. Use temp to hold the value of i and then assign j’s value to i. The originalvalue of i, which was saved in temp, can now be assigned to j.
Read Morewrite some code that swaps the values in i and j by copying their values to itemp and jtemp, respectively, and then copying itemp and jtemp to j and i, respectively.
LANGUAGE: C++ CHALLENGE: Given two int variables, i and j, which have been declared and initialized, and two other int variables, itemp and jtemp, which have been declared, write some code that swaps the values in i and j by copying their values to itemp and jtemp, respectively, and then copying itemp and jtemp to j and i, respectively.
Read More