Question

In: Computer Science

int 50+20 * (50/4) /4

int

50+20 * (50/4) /4

Solutions

Expert Solution

Answer

The answer is 110.

This equation is read as 50+((20*(50/4))/4).

Because it is int n type decimal values are rounded off in every bracket, resulting 110.

To understand this read the rule of precendence :

Rules of Operator Precedence:

  1. Operators in expressions contained within pairs of parentheses are evaluated first. Parentheses are said to be at the “highest level of precedence.” In cases of nested, or embedded, parentheses, such as
        ( ( a + b ) + c )                               

    the operators in the innermost pair of parentheses are applied first.

  2. Multiplication, division and remainder operations are applied next. If an expression contains several multiplication, division and remainder operations, evaluation proceeds from left to right. Multiplication, division and remainder are said to be on the same level of precedence.
  3. Addition and subtraction operations are evaluated next. If an expression contains several addition and subtraction operations, evaluation proceeds from left to right. Addition and subtraction also have the same level of precedence, which is lower than the precedence of the multiplication, division and remainder operations.
  4. The assignment operator (=) is evaluated last.

Applying rule 2 after the parenthesis gives us the output as 110.


Related Solutions

A.) myNums is an array of 50 elements of type int and k is an int...
A.) myNums is an array of 50 elements of type int and k is an int variable. For which one we get the index of out of bounds? a. for (k = 0; k <= 49; k++)     cout << myNums[k] << " "; b. for (k = 1; k < 50; k++)     cout << myNums[k] << " "; c. for (k = 0; k <= 50; k++)     cout << myNums[k] << " "; d. for (k =...
4. Class Observations Frequency 20-35 20,28,32,35 4 35-50 39,42,46,47,48,48 6 50-65 53,56,57,58,59,62,63,63 8 65-80 67,71,75,77 4...
4. Class Observations Frequency 20-35 20,28,32,35 4 35-50 39,42,46,47,48,48 6 50-65 53,56,57,58,59,62,63,63 8 65-80 67,71,75,77 4 80-98 81,93 2 1.Construct the relative frequency distribution that corresponds to the frequency distribution from the data set in problem # 4. 2.Construct the cumulative frequency distribution that corresponds to the frequency distribution from the data set in problem # 4. 3.Consider the Histogram using the frequency distribution from the data set in problem # 4. Enter the numbers that label the horizontal axis...
Question 1 For the dataset: 20, 20, 10, 10, 40, 50, 20, 30, 10, 20, 50,...
Question 1 For the dataset: 20, 20, 10, 10, 40, 50, 20, 30, 10, 20, 50, 60, 20, 30, 50, 20, 30, 40, 30, 30, 30, 50, 40 calculate the max, min, mode, median and mean.(20%) Draw a boxplot with inner and outer fence For the data in part (i), if the value 60 was replaced by 2000, what would you call this value in the dataset? What could be the explanation for such a value? How can you through...
#include <stdio.h> #include<math.h> int main (void). { int I, j, k, num_elem; double x[20], y[20],z[20]; FILE*infile,...
#include <stdio.h> #include<math.h> int main (void). { int I, j, k, num_elem; double x[20], y[20],z[20]; FILE*infile, *outfile; infile = fopen (“c6_3.IN”, “r”); outfile = fopen (“c6_3.OUT”, “w”); k = fscanf (infile, “%lf %lf”, &x[0], &y[0]); fprintf (outfile,”k= %d\n”,k); fprintf (outfile, “value of EOF = %d\n”, EOF); i =1; while ( fscanf(infile, “%lf %lf”, &x[i], &y[i]) != EOF) i++; num_elem =I; fprintf(outfile,” x[i] y[i] z[i]\n”); For (j=0; j<num_elem; j++) { Z[j] =sqrt(x[j] *x[j] +y[j]*y[j]); fprintf(outfile,”%7.1f %7.1f %7.1f\n”, x[j] , y[j], z[j]);...
#include <iostream> using namespace std; void count( int begin[], int end[] ) { int index, current[4]...
#include <iostream> using namespace std; void count( int begin[], int end[] ) { int index, current[4] = { begin[0], begin[1], begin[2], begin[3] }; add: goto print; carry: if ( current[index] < end[index] - 1 ) { current[index]++; goto add; } else if ( index > 0 ) { current[index] = begin[index]; index--; goto carry; } else return; print: cout << current[0] << current[1] << current[2] << current[3] << endl; index = 3; goto carry; } int main( ) { int...
#include <iostream> #include <iomanip> using namespace std; int main() {     int studentid, numberreverse[20], count =...
#include <iostream> #include <iomanip> using namespace std; int main() {     int studentid, numberreverse[20], count = 0, maximum = 0, minimum = 0;     cout << "Enter your student ID number: ";     cin >> studentid;     cout << "Student ID Number = " << studentid << endl;     while (studentid != 0)     {          numberreverse[count] = studentid % 10;          if (count == 0)          {              minimum = numberreverse[count];              maximum = minimum;          }          else...
2. Let the function fun be defined as int fun(int*k) {       *k += 4;       return...
2. Let the function fun be defined as int fun(int*k) {       *k += 4;       return 3 * (*k) - 1; } Suppose fun is used in a program as follows: void main() {       int i = 10, j = 10, sum1, sum2;       sum1 = (i / 2) + fun(&i);       sum2 = fun(&j) + (j / 2); } What are the values of sum1 and sum2 a. operands in the expressions are evaluated left to right? b. operands...
code from assignment 1 #include #include using namespace std; const int nameLength = 20; const int...
code from assignment 1 #include #include using namespace std; const int nameLength = 20; const int stateLength = 6; const int cityLength = 20; const int streetLength = 30; int custNomber = -1; // Structure struct Customers { long customerNumber; char name[nameLength]; char state[stateLength]; char city[cityLength]; char streetAddress1[streetLength]; char streetAddress2[streetLength]; char isDeleted = 'N'; char newLine = '\n'; int zipCode; }; int main() { ofstream file; file.open("Customers.dat", fstream::binary | fstream::out); char go; long entries = 0; struct Customers data; do...
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num ==...
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num == 0) return 0; else if (num > 100) return -1; else     return num + tq( num – 1 ); } Group of answer choices: 0 4 -1 10 Q2: Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)? int mystery(LLNode<Integer> list) {    if (list.getLink() ==...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5,...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5, 6, 7, 8}; bArray = aArray; System.out.print(bArray[2]); 1 points    QUESTION 6 What is printed? public static void main(String[] args) { int[] aArray = { 1, 2, 3, 4 }; System.out.print(aArray[2]); int i = aMeth(aArray); System.out.print(i + "" + aArray[2]); } public static int aMeth(int[] iArray) { for (int i = 0; i < iArray.length; i++) { iArray[i]++; } int[] bArray = { 5,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT