1. What is the value of the arithmatic epxression: a+b%c int a=7; int b=10; int
ID: 3537746 • Letter: 1
Question
1. What is the value of the arithmatic epxression: a+b%c
int a=7;
int b=10;
int c=3;
2. a and b are int variables. Which expression always evaluate to the same value?
int exp A= a+b*c;
int exp B= (a+b)*c;
int exp C= a + (b*c);
3.This code is design to find the average of a and b.
int a=0;
int b=4;
double average= a+b/2.0;
Is this code correct?
a.) Yes, the code is correct.
b.) No, the sum of a and b should be divided by 2.
c.) No, the variables a and b should have type double.
d.) No, the average should have type int.
e.) No, the sum of a and b must be a parenthesis.
4. What value is assigned to z given these variables definitions,
int p=5;
int s=20;
int x=6;
int z= p+3*x-5;
5. What would be teh best choice for the datat type of a variable used to store number of students in a class?
a. float
b. int
c. char
d. string
e. bool
Explanation / Answer
please rate - thanks
1. What is the value of the arithmatic epxression: a+b%c
int a=7;
int b=10;
int c=3;
a+b%c
7+10%3 % is done 1st 10/3 = 3 remainder 1
7+1
8
2. a and b are int variables. Which expression always evaluate to the same value?
int exp A= a+b*c; 7+10*3 = 7+30 = 37
int exp B= (a+b)*c; (7+10)/3 =17/3 =5.66
int exp C= a + (b*c); 7+(10*3) = 7+37 = 37
A & C are always the same
3.This code is design to find the average of a and b.
int a=0;
int b=4;
double average= a+b/2.0;
Is this code correct?
a.) Yes, the code is correct.
b.) No, the sum of a and b should be divided by 2.
c.) No, the variables a and b should have type double.
d.) No, the average should have type int.
e.) No, the sum of a and b must be a parenthesis.
answer is e should be (a+b)/2.0
4. What value is assigned to z given these variables definitions,
int p=5;
int s=20;
int x=6;
int z= p+3*x-5;
z = 5 + 3 * 6 - 5
5 + 18 - 5
23 - 5
18
as for your comment--you are either missing something or your choices are wrong-I've been doing this 40 years, answer is 18
5. What would be teh best choice for the datat type of a variable used to store number of students in a class?
a. float
b. int
c. char
d. string
e. bool
number of students is always a whole number, so the answer is int (b)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.