Question

In: Computer Science

The following variables are declared as follow: int Var1 = 9, Var2 = 2, Var3 =...

The following variables are declared as follow:

int Var1 = 9, Var2 = 2, Var3 = 0;

What will the output of the following statements be?

Var3 = Va1 / Var2;

Var2 = Var2 / Var1;

out.print(Var3);
out.print(Var2);
int Var1 = 19, Var2 = 12,

oy.print(Var1 % Var2);
oy.print(Var1 % 3.0);
3. Var1 += 5;

System.oy.print(Var1);

Solutions

Expert Solution

Answer :-

int Var1 = 9, Var2 = 2, Var3 = 0;                      

Var3 = Va1 / Var2;         // var3 = 9 / 2 = 4 (int type)

Var2 = Var2 / Var1;       // var2 = 2 / 9 = 0 ( int type )

out.print(Var3);       // print 4                                                                                                   Output : 4

out.print(Var2);        // print 0                                                                                                     0

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

int Var1 = 19, Var2 = 12,

oy.print(Var1 % Var2);      // print   var1 % var2 = 19 % 12 = 7 (19 mod 12)                                 Output : 7

oy.print(Var1 % 3.0);       // print var1 % 3 = 19 % 3 = 1 ( 19 mod 3)                                                           1

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3. Var1 += 5;          // var1 = var1 + 5 = 19 + 5 = 24

System.oy.print(Var1); // print 24                                                                                                   Output : 24

------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Related Solutions

1. in the code below, 2 variables (largest and smallest) are declared. use these variables to...
1. in the code below, 2 variables (largest and smallest) are declared. use these variables to store the largest and smallest of three integer values. you must decide what other variables you will need and initialize them if appropriate. 2. write the rest of the program using assignment statements, if statements, or if else statements as appropriate. There are comments in the code that tell you where you should write your statements 3. compile and execute. Output should be: The...
Given the following int variables which represent a date, int day; // 0-6 for Sunday-Saturday int...
Given the following int variables which represent a date, int day; // 0-6 for Sunday-Saturday int month; // 1-12 for January-December int date; // 1-31 int year; // like 2020 Define the function void tomorrow(int& day, int& month, int& date, int& year); which updates the variables to represent the next day. Test in main().
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that...
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that can be used to display values of the first, third, and seventh elements of the array. b. Write a scanf() statement that can be used to enter values into the first, third, and seventh elements of the array. c. Write a for loop that can be used to enter values for the complete array. d. Write a for loop that can be used to...
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int...
Suppose A is (10, 2, 5, 9, 1, 8, 2, 4). Consider the function: int BBOX(int n, int k)             if (n <= 0) return 0;             else if (A[n] < k) return (1+ 2*BBOX(n-1,k+1));             else return BBOX(n-1,k-2);             Find BBOX(8, 5)
Evaluate the truth values of the following conditions given the values of the declared variables. NOTE:...
Evaluate the truth values of the following conditions given the values of the declared variables. NOTE: Conditions formed using relational or equality operators (>, <, >=, <=, ==, !=) are relational conditions. Conditions formed using logical operators [&& (AND), || (OR), & (boolean AND), | (boolean inclusive OR), ^ (boolean exclusive OR) are complex conditions. Variables boolean gameLoss = false; int points = 15; boolean championship = false; Conditions: Evaluate then Indicate the truth value produced by the relational conditions...
Using the following array: //may be declared outside of the main function const int NUM_Games =4;...
Using the following array: //may be declared outside of the main function const int NUM_Games =4; //may only be declared within the main function int scores[NUM_GAMES] = {122, 76, 92, 143}; Write a C++ program to run a menu-driven program with the following choices: 1) Display the scores 2) Change a score 3) Display game with the highest score 4) Display a sorted list of the scores 5) Quit Write a function called getValidScore that allows a user to enter...
c++ Exercise 1: Make a struct “Fate” that contains the following variables: int month, int year,...
c++ Exercise 1: Make a struct “Fate” that contains the following variables: int month, int year, int day. Make another struct Product that would contain the following variables: 1- Product name. 2- An array for the product ingredients. Set its max size to 3. 3- Product date of expiration. Use the date struct you made. Use those structs in entering the data for two products of your choice. Make a function printProduct(Product product) that prints out the contents of the...
Explain in detail, in your own words, what the following statements mean (suppose variables are declared...
Explain in detail, in your own words, what the following statements mean (suppose variables are declared and initialized: x declared as double, ch declared as char, s declared as string). Q3.1 ifstream input("numbers.txt"); Q3.2 ++num; Q3.3 static_cast(x); Q3.4 bool b2 = 0; Q3.5 srand(time(0)); Q3.6 floor(x); Q3.7 isupper(ch)); Q3.8 cout << s[0] << endl; Q3.9 cout << setw(9) << x; Q3.10 cout << setprecision(3) << x << "\n ";
Assume that the following variables have been declared: String a = “Ready, Set, Go!”; String b...
Assume that the following variables have been declared: String a = “Ready, Set, Go!”; String b = a.substring(5, 10); char b1 = b.charAt(2); Evaluate the following expression: 1. Character.isLowerCase(b1) 2. b1 + 5 3. b + 5 4. Character.toLowerCase(b1) 5. a.charAt(2 + a.indexOf(“e”))
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number;...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number; Scanf (“%d”, & number); if (number % 2 ==0) { printf (“Even\n”); } else { printf(“Odd\n”); } Return 0; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT