Question

Operator exercises: int x; x = 8/3; x = 11 % 4; x = 31%10; x...

Operator exercises:

int x;

  1. x = 8/3;
  2. x = 11 % 4;
  3. x = 31%10;
  4. x = 1/2;
  5. x = 5/3;
  6. x = 5.0/3;
  7. x = 12 - 4 / 3 – 8 * 2;
  8. x = 24 / 5 + 1 * 4;
  9. x = 12 - 9 + 4 * 2 + 3 % 2;
  10. x = 2 * (5 - 3) + 7;

  Assume the following order of operations:

!

&&

||

Give the value of x,

given A = TRUE, B = FALSE, C = TRUE, D = TRUE. E = 10, F = 15

    bool x;

13.         x = A && B

14.         x = C || D

15.         x = !C

16.         x = !(A && D)

17.         x = !C && B

18.         x = ( E < 10) && (E == F)

19.         x = A && B || C && D

20.         x = !(A && B) || !(D && C)

For each of the following problems:

  1. Write an IPO diagram.
  2. Design a solution using C-like code.
  3. Trace.
  1. Write a program that inputs a number and displays the square and the cube. Trace for 3, -2, and 0.
  2. Write a program that computes your salary. You input your hours worked. Your pay rate doesn’t change. Trace for 10 hours and 40 hours.
  3. Write a program that calculates a restaurant bill where you input three items – a drink, an entrée and a dessert. Include tax at 6% and tip at 20%. Do 2 traces.
  4. Write a program that inputs a temperature in Celsius and converts it to Fahrenheit. (F = (1.8 x C) + 32.). Do 2 traces.

Sample for number 1 is below.

A.

INPUT

PROCESS

OUTPUT

B.

int main()

{

}

C.

num

square

cube

Output

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int...
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int y){ x = (x*y) mod 3; y = y – x; } main(){ i = 0; a[0] = 1; a[1] = 2; a[2] = 0; f(i, a[i]); print(“%d %d %d %d\n”, i, a[0], a[1], a[2]); f(a[i], a[i]); print(“%d %d %d\n”, a[0], a[1], a[2]); }
Given this array: int sequence[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 1,...
Given this array: int sequence[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 1, 2 }; Write a C++ program to ask the user to enter a number, if the number can be found in the array, your program should display "Found". Otherwise, your program should display "Not found". For example, if the user enters 7, your program should display "Found". If the user enters 11, your program should display "Not found".
Perform a box trace. Show trace int[] arr = {8, 10, 4, -2, 2, 8, 6,...
Perform a box trace. Show trace int[] arr = {8, 10, 4, -2, 2, 8, 6, 4, 3, 9}; System.out.println(fun(arr, 7, 1)); int fun(int nums[], int aa, int bb) { int ret; System.out.println(aa); if(aa <= 1) ret = nums[bb]; else ret = nums[bb-1] + fun(nums, aa - 2, bb +1); System.out.println(ret); return ret; }
1.    Given the following segment of code: (If there is nothing output, write None.) int x;...
1.    Given the following segment of code: (If there is nothing output, write None.) int x; int y; cin >> x; cin >> y; while (x > y) {     x -= 3;     cout << x << " "; } cout << endl;        a.    What are the output and final values of x and y when the input is 10 for x and 0 for y? [2, 2, 2]               Output                                                                                                                                                                                                    x = ______________                                                                                                                                                                                                   ...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
Write a C function to compute the following output (int) based on two input (int) variables:...
Write a C function to compute the following output (int) based on two input (int) variables: output = a*a + b*b - 2*a*b If the value of output is '0', then return -1 instead. Call the C function 4 times from main() with values of 'a' and 'b' as follows and print output values for each case. a = 3, b = 4 a = 1, b = 1 a = -2 b = 3 a = -4 b =...
#include <stdio.h> #include <stdlib.h> int main () { int k; int aux; int size = 8;...
#include <stdio.h> #include <stdlib.h> int main () { int k; int aux; int size = 8; int x[8] = {2, 3, 5, 7, 11, 13, 17, 19}; scanf("%d",&k); aux = x[k]; for (int i = k; i < size - 1; i++) x[i] = x[ i + 1]; x[ size - 1] = aux;   for (int i = 0; i < size; i++) printf("%d ", x[i]); } change this program to Write a program to remove an element from an...
int b = 4, p = 5, r = 2, v = 8; double x; Write...
int b = 4, p = 5, r = 2, v = 8; double x; Write the JAVA statement to perform the following: Assign x the value of p multiplied by v - 6 all divided by the square root of the sum of b and p
d = int(input('Enter the date: ')) m = int(input('Enter the month: ')) y = int(input('Enter the...
d = int(input('Enter the date: ')) m = int(input('Enter the month: ')) y = int(input('Enter the year: ')) if m<3: m = m + 12 y = y - 1 a = (2*m) + (6*(m+1)/10) b = y + (y/4) + (y/400) - (y/100) c = d + a + b + 1 f = c / 7 if f == 0: print ('Sunday') elif f == 1: print ('Monday') elif f == 2: print ('Tuesday') elif f ==3: print...