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++: Early Objects (10th Edition)
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)
- (Practice) a. Write a declaration statement to declare that the variable count will be used to store an integer. b. Write a declaration statement to declare that the variable volt will be used to store a floating-point number. c. Write a declaration statement to declare that the variable power will be used to store a double-precision number. d. Write a declaration statement to declare that the variable keychar will be used to store a character.arrow_forwardWrite C++ statements that accomplish the following. Declare int variables x and y. Initialize x to 25 and y to 18. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'. Declare and initialize a double variable payRate to 12.50 Copy the value of an int variable firstNum into an int variable tempNum Declare int variables to store four integers.arrow_forward2- Number of basic operations of the following statement is equal to : for ( int i = 0 ; i< = 1 ; ++i) System.out.println( "X+1"+"Y"); A- 5 B- 6 C- 7 D- Nonearrow_forward
- Q 3) Write C# statements to accomplish each of following tasks: Assign the sum of x and y to w, and increment x by 1 with ++. Use only one statement and ensure that original value of x is used in statement. Test whether variable count is greater than 20. If it is, display “Count is greater than 20”. Decrement the variable x by 1, then subtract it from the variable total. Use only one statement. Calculate the remainder after q is divided by divisor, and assign the result to q. Write this statement in two different ways.arrow_forwardSuppose x and y are int variables and symbol is a char variable. Assume the following input data:38 26 *67 3324 $ 55 # 34# & 63 85What value (if any) is assigned to x, y, and symbol after each of the following statements executes? (Use the same input for each statement.)a. cin >> x >> y;cin.ignore(100, '\n');cin >> symbol;b. cin >> x;cin.ignore(100, '*');cin >> y;cin.get(symbol);c. cin >> y;cin.ignore(100, '\n');cin >> x >> symbol;d. cin.get(symbol);cin.ignore(100, '*');cin >> x;cin.ignore(100, '\n');cin >> y; e. cin.ignore(100, '\n');cin >> x >> symbol;cin.ignore(100, '\n');cin.ignore(100, '&');cin >> y;arrow_forwardLet a, b, c be integer variables having values 2, 4, 5 respectively and x, y, z be float variables having values 1.1, 2.5, 3.6 respectively. Determine the value of each arithmetic statements. a + b + c a % b a / b a * (b / c) x + y + z x / (y + z) x % y Test B. Copy and answer the following:Interpret and determine the value of each statement. Let integer x = 2, y=5, z = 10 (x<y)&&(y>=z)||(z==x) (y>=x) || !(z==10) && (x<z&&y==2||z>=y) (z%y==x)&&( (y + z)/3>=x)arrow_forward
- Write a statement or a set of statements to accomplish each of the following tasks:a) Sum the odd integers between 1 and 99 using a for statement. Use the unsigned integervariables sum and count.b) Print the value 333.546372 in a field width of 15 characters with precisions of 1, 2, 3, 4and 5. Left justify the output. What are the five values that print?c) Calculate the value of 2.5 raised to the power of 3 using the pow function. Print the result with a precision of 2 in a field width of 10 positions. What is the value that prints?d) Print the integers from 1 to 20 using a while loop and the counter variable x. Print onlyfive integers per line. [Hint: Use the calculation x % 5. When the value of this is 0, printa newline character, otherwise print a tab character.]e) Repeat Exercise 4.3(d) using a for statement.arrow_forwardIdentify and correct the mistakes in the following statements. Each statement may contain more than one mistake. scanf("%d", int); printf("%c\n", 'Hello'); printf(%f, 123.456);arrow_forward(Diameter, Circumference and Area of a Circle) Write a program that reads in the radiusof a circle and prints the circle’s diameter, circumference and area. Use the constant value 3.14159for π. Perform each of these calculations inside the printf statement(s) and use the conversion specifier %f. [Note: In this chapter, we’ve discussed only integer constants and variables. In Chapter 3we’ll discuss floating-point numbers, i.e., values that can have decimal points.]arrow_forward
- 3. Write Python expressions or assignments as specified:a. Assign x to be 5, y to be 10, and z to be 8.b. Write an expression that evaluates to the average of x, y and z.c. Write an expression that evaluates to the largest value among x, y, and z.d. Write an expression that evaluates to the median value among x, y, and z (Hint:the median of a, b, and c is a+b+c - max{a,b,c} - min{a,b,c}.)arrow_forward30 Suppose a, b, and sum are int variables and c is a double variable. What value is assigned to each variable after each statement executes? Suppose a = 6, b = 3, and c = 2.2. (14) a b c sum sum = static_cast<int>(a + b + c); __ __ __ __ b += c * a; __ __ __ __ c -= a; __ __ __ __ a *= 2 * b - c; __ __ __ __arrow_forwardWrite assignment statements that perform the following operations with the variables a and b (Python)A. Adds 2 to a and stores the result in bB. Multiplies b times 4 and stores the result in aC. Divides a by 3.14 and stores the result in bD. Subtracts 8 from b and stores the result in aarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning