If an expression contains double, int, float, long, then the
whole expression will be promoted into which of these data
types?
a) long
b) int
c) double
d) float
Answer: Option C: double
Explanation:
since double data type is bigger than int, float, long. hence the whole expression will be converted to double
If an expression contains double, int, float, long, then the whole expression will be promoted into...
Why float f = 10d will cause the compiler error/ and why int and double did not cause any compiler error ? public class Main { public static void main(String[] args) { // write your code here char c = 38; int i = 'a'; double d = 10f; double d2 = 10; float f = 10d; System.out.println(a + b); } }
Which of the following Python data types can hold decimals like 3.14 ? float int bool long
S. Modułus operator can operate upon A. double B、 float C. char D. int E. C and D
Consider the following code: 1. float foo (int a, int b, int c, int d, float e) { 2. float e; 3. if (a == 0) { 4. return 0; 5. } 6. int x = 0; 7. if ((a==b) || ((c == d) && bug(a) )) { 8. x=1; 9. } 10. e = 1/x; 11. return e; 12. } Function bug(a) should return a value of true when passed a value of a=1. Build: • a test suite...
Per its signature, what does the following method return upon conclusion? public double[] trainer(int brock, float grit){ A. An integer value. B. A floating point number. C. A double value. D. An address. E. None of the above.
1. A(n) ____________________ is a variable or expression listed in a call to a function. 2. The pass by ____________________ mechanism must be used if the calling code is to receive information back from the function. 3. True or False? If there are several items in a parameter list, the compiler matches the parameters and arguments by their relative positions in the parameter and argument lists. 4. True or False? In C++, a function definition may have another function definition...
QUESTION 1 Given two double variables named x and y, which of the following statements could you use to initialize both variables to a value of 0.0? a. x | y = 0.0; b. x = y = 0.0; c. x, y = 0.0; d. none of the above 1 points QUESTION 2 When you use a range-based for loop with a vector, you a. can avoid out of bounds access b. must still use a counter variable c....
Q10: Which of the following is not an error (either a syntax error or a logic error)? Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false. Spelling a key word (such as while or if) with a capitalized first letter. Using a condition for a while statement that is initially false. An infinite loop. Q11: How many times is the body of the loop below executed? int counter;...
PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float b = 0.5; float c = a + b; int bits = 0; while (c != a) { bits = bits + 1; b = b / 2; c = a + b; } printf("%d\n",bits); return 0; }
In c++ code and test a function with prototype float except(int arg); that accepts an int argument and returns the expression 1.0 / arg if arg != 0; otherwise, except() throws an exception of type string. A suitable message might be “Error – attempt to divide by zero”.