Concept explainers
Write assignment statements that perform the following operations with int variable i, double variables d1 and d2, and char variable c.
A) Subtract 8.5 from d2 and store the result in d1.
B) Divide d1 by 3.14 and store the result in d2.
C) Store the ASCII code for the character 'F' in c.
D) Add 1 to i and store the new value back in i.
E) Add d1 to the current value of d2 and store the result back in d2 as its new value.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Programming in C
Starting Out With Visual Basic (7th Edition)
Artificial Intelligence: A Modern Approach
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- Factorial) The factorial of a nonnegative integer n is written n! (pronounced “n factorial”) and is defined as follows:For example, 5!= 5.4.3.2.1 , which is 120. Use while statements in each of the following:A. Write a program that reads a nonnegative integer and computes and prints its factorial.B. Write a program that estimates the value of the mathematical constant e by using the formula:Prompt the user for the desired accuracy of e (i.e., the number of terms in the summation).C. Write a program that computes the value of by using the formula Prompt the user for the desired accuracy of e (i.e., thenumber of terms in the summation).arrow_forwardQ2) Write a program that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word "Yes". If the sentence ends with a question mark and the input contains an odd number of characters, display the word "No". If the sentence ends with an exclamation point (!), display the word "Wow". In all other cases, display the words " you always say "followed by the input string enclosed in quotes" ". Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Sample Input#1: Please enter a one line question or statement. How are you? Sample Output#1: Yes Sample Input #2: Please enter a one line…arrow_forward61. State true or false: If I = read(Q) and J = read(Q) then the order of I and J does not matter. a. True b. False c. May be d. Can't sayarrow_forward
- Declare int variables x and y. Initialize x to 25 and y to 18.arrow_forwardWrite C code that calculates and prints the volumes of different shapes (Sphere and Frustum ). The program asks the user to read a character (ch). Every time ch is entered, the program does the following: - if ch is 's', then the program asks the user to enter a float (d) and prints the volume of the sphere. V = Id3 6. - if ch is 'f', then the program asks the user to enter three floats (h, b ,and d) and prints the volume of the frustum. V = IT h 12 Vdb +arrow_forwarda) Write a program that defines variables a, b, c, d as float and Num2 as integer. Solve the following expression on notebook by supposing some values of each variable, then execute your program for the same values and see the difference if any. la * (b - c / d) + ++ Num2 where a, b, c and d are float type variables. b) Write a program that defines variables Num1, Num2, Num3, and Num, as integer Solve the following expression on notebook by supposing some values of each variable, then execute your program for the same values and see the difference if any. Result= Num1 + Num2 / Num3 + Num + Num2++ where Num1, Num2 and Num3 are all integer type variables c) Write a program that defines variables m, n, p, and amount, as integer Solve the following expression on notebook by supposing some values of each variable, then execute your program for the same values and see the difference if any. (m + n) / (p + amount)arrow_forward
- int power(int base,int exp); *This function accepts the arguments for base and exponent and returns power. The algorithm is to repeatedly multiply the value of the base to how many time the value of exponent.* For example: Test Input Result printf("%d",power(2,5)); 2 32 5 printf("%d",power(3,4)); 3 81 4 -Use C language, please. Thank you.arrow_forwarduse C++ codingarrow_forwardC++ program E x e r c i s e 3Problem StatementInterest on Credit card accounts can be quite high. Most credit card companies compute intereston an average daily balance. Here is an algorithm for computing the average daily balance andthe monthly interest charge on a credit.Steps:Step 1 - Multiply the net balance shown on the statement by the number of days in the billingcycle.Step 2 - Multiply the net payment received by the number of days the payment was receivedbefore the statement date.Step 3 - Subtract the result of the calculation in step 2 from the result of the calculation in step 1.Step 4 - Divide the result of step 3 by the number of days in the billing cycle. This value is theaverage daily balance.Step 5 - Compute the interest charge for the billing period by multiplying the average dailybalance by the monthly interest rate.Specific Example:Here is an example to illustrate the algorithm. Suppose a credit card statement showed a previousbalance of $850. Eleven days before the…arrow_forward
- 5) Write a program that reads three numbers and prints "increasing" if they are in increasing order, "decreasing" if they are in decreasing order, and "neither" otherwise. Here, "increasing" means "strictly increasing", where each value is less than the next. The sequence 3 4 4 would not be considered increasing, for example. 6) Repeat Exercise 5, but first ask the user whether "increasing/decreasing" should be "strict" or "lenient". In lenient mode, the sequence 3 4 4 is "increasing", and the sequence 4 44 is both increasing and decreasing.arrow_forward9- Write a program which read a number of 3 digits and check if (units, tens, hundreds) digit is greater than 5, convert this digit to 5. FOR eg. 147 After check 145 983 After check 553arrow_forward39. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or false. a. True b. False c. May be d. Can't sayarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,