# Tag: C++

## Assume that name is a variable of type string that has been assigned a value. Write an expression whose value is the last character of the value of name. So if the value of name were “Blair” the expression’s value would be ‘r’.

LANGUAGE: C++ CHALLENGE: Assume that name is a variable of type string that has been assigned a value. Write an expression whose value is the last character of the value of name. So if the value of name were “Blair” the expression’s value would be ‘r’....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + … + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333… and so on.

LANGUAGE: C++ CHALLENGE: In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + … + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333… and so on. Assume that n is an integer variable whose value is some integer N greater...

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## The dimensions (width and length) of room1 have been read into two variables: width1 and length1. The dimensions of room2 have been read into two other variables: width2 and length2. Write a single expression whose value is the total area of the two rooms.

LANGUAGE: C++ CHALLENGE: The dimensions (width and length) of room1 have been read into two variables: width1 and length1. The dimensions of room2 have been read into two other variables: width2 and length2. Write a single expression whose value is the total area of the two rooms....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Diamond Pattern Write a program that displays the following pattern

LANGUAGE: C++ CHALLENGE: Diamond Pattern Write a program that displays the following pattern: * *** ***** ******* ***** *** * Output description: Seven lines of output as follows: The first consists of 3 spaces followed by a star. The second line consists of 2 spaces followed by a 3 stars. The third consists of one space followed...

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Land Calculation One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with 389,767 square feet.

LANGUAGE: C++ CHALLENGE: Land Calculation One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of acres in a tract of land with 389,767 square feet....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.

LANGUAGE: C++ CHALLENGE: Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates , it prints out the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even...

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Given a two-dimensional array of integers named q, with 2 rows and 4 columns, write some code that puts a zero in every element of q.

LANGUAGE: C++ CHALLENGE: Given a two-dimensional array of integers named q, with 2 rows and 4 columns, write some code that puts a zero in every element of q. Declare any variables needed to help you....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## You are given a 6×8 (6 rows, 8 columns) array of integers , x, already initialized and three integer variables : max, i and j.

LANGUAGE: C++ CHALLENGE: You are given a 6×8 (6 rows, 8 columns) array of integers , x, already initialized and three integer variables : max, i and j. Write the necessary code so that max will have the largest value in the array x....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Given an array arr of type int , along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j]. Declare any additional variables as necessary.

LANGUAGE: C++ CHALLENGE: Given an array arr of type int , along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j]. Declare any additional variables as necessary....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Given a type Money that is a structured type with two int fields, dollars and cents declare an array monthlySales with 12 elements of type Money.

LANGUAGE: C++ CHALLENGE: Given a type Money that is a structured type with two int fields, dollars and cents declare an array monthlySales with 12 elements of type Money....

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Write a single statement that assigns a new value to the element of the array indexed by j. This new value should be equal to twice the value stored in the next element of the array (i.e. the element after the element indexed by j).

LANGUAGE: C++ CHALLENGE: An array of int named a that contains exactly five elements has already been declared and initialized . In addition, an int variable j has also been declared and initialized to a value somewhere between 0 and 3. Write a single statement that assigns a new value to the element of the array...

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

## Given an array a and a variable n that contains the number of elements in a, write an expression for the corresponding element of a[i].

LANGUAGE: C++ CHALLENGE: We informally define the term “corresponding element” as follows: The first element in an array and the last element of the array are corresponding elements. Similarly, the second element and the element just before the last element are corresponding elements. The third element and the element just before the element just before the...

This content requires that you purchase additional access. The price is \$2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.