Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

### Search & Filtering

Create an application that calculates your daily driving cost, so that you can estimate how much money could be saved by carpooling, which also has other advantages such as reducing carbon emissions and reducing traffic congestion. The application should input the following information and display the user’s cost per day of driving to work:

a) Total miles driven per day.

b) Cost per gallon of gasoline.

c) Average miles per gallon.

d) Parking fees per day.

e) Tolls per day.

The function Power, which raises the integer number x to the power n, can be defined recursively as follows: Power(x, n) = 1 for n = 0 Power(x, n) = x * Power(x, n-1) for n > 0 (i) Using the above definition write the recursive function Power(x, n) in C. (ii) Rewrite the recursive function Power(x, n) in an iterative form. (iii) Write the main function and test the above written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii).

The function Power, which raises the integer number x to the power n, can be defined recursively as follows: Power(x, n) = 1 for n = 0 Power(x, n) = x * Power(x, n-1) for n > 0 (i) Using the above definition write the recursive function Power(x, n) in C. (ii) Rewrite the recursive function Power(x, n) in an iterative form. (iii) Write the main function and test the above written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii).

Instructions:

Using the do…while() loop, continuously scan for integers, but add up only all the positive integers and store the total in one variable.

The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers.

Input

1. A series of integers

Output

The first multiple lines will contain message prompts to input the integers.

The last line contains the total of all positive integers inputted.

Enter·n:·2

Enter·n:·3

Enter·n:·4

Enter·n:·-1

Enter·n:·-5

Enter·n:·1

Enter·n:·0

Total·of·all·positives·=·10

Instructions:

Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable.

The loop shall only terminate for the following reasons:

A negative decimal number is inputted (but still included in the total sum)

The total sum reaches 100.0 or more

Input

1. A series of float numbers

Output

The first multiple lines containing message prompts for float numbers.

The last line contains the sum with 2 decimal places.

Enter·a·number:·1.1

Enter·a·number:·1.2

Enter·a·number:·1.3

Enter·a·number:·1.4

Enter·a·number:·-1.0

Sum·=·4.00

Instructions:

Using a do…while() loop, continuously scan for characters (one per line) and print it out afterwards. Remember to place a space before the character's placeholder when scanning so that the newline characters will be ignored and the correct values will be scanned.

The loop shall terminate due to either of the following reasons:

The inputted character is a vowel

The number of inputted characters has already reached 5.

For all of the test cases, it is guaranteed that if the number of inputted characters is less than 5, then there must be a vowel from among the inputted characters. Also, it is guaranteed that all the characters are in lowercase.

Input

1. A series of characters

Output

Multiple lines containing message prompts for characters.

Enter·a·character:·c

c

Enter·a·character:·f

f

Enter·a·character:·a

a

Instructions:

Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.

Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.

Input

1. Series of integers

Output

Multiple lines containing message prompts for integers and their squares.

Enter·n:·2

Square·=·4

Enter·n:·6

Square·=·36

Enter·n:·0

Square·=·0

The function Power, which raises the integer number x to the power n, can be defined recursively as follows:

Power(x, n) = 1 for n = 0

Power(x, n) = x * Power(x, n-1) for n > 0

(i) Using the above definition write the recursive function Power(x, n) in C.

(ii) Rewrite the recursive function Power(x, n) in an iterative form.

(iii) Write the main function and test the above-written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii).

The function Power, which raises the integer number x to the power n, can be defined recursively as follows:

Power(x, n) = 1 for n = 0

Power(x, n) = x * Power(x, n-1) for n > 0

(i) Using the above definition write the recursive function Power(x, n) in C.

(ii) Rewrite the recursive function Power(x, n) in an iterative form.

(iii) Write the main function and test the above-written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii)

Instructions:

1. Input two integer values. The first one shall accept any integer from 0-9 and the other one shall take a non-zero positive integer.
2. Using a while loop, count how many of the first integer (0-9) is present in the digits of the second inputted integer and print the result (see sample input and output for example).
3. Tip #1: You have to use your knowledge from the previous problems in looping through the digits of a number: % 10 to get the rightmost digit, while / 10 to remove the rightmost digit. Make sure to solve the previous problems first.

Input

1. First integer

2. Second integer

Output

The first line will contain a message prompt to input the first integer.

The second line will contain a message prompt to input the second integer.

The last line contains the number of times the first integer occurred in the digits of the second integer.

Enter·the·first·integer·(0·-·9):·2
Enter·the·second·integer:·124218
Occurrences·=·2
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS