Hey guys
I'm total newbie at programming and need a bit of help with a quiz for my programming class. Help would be greatly appreciated.
1. Which of the following data types will store the largest numeric value?
a. Long
b. float
c. double
d. integer
e. bool
2. Which of the following will cause an error when compiling the program?
a. int x = 0; float y; double z;
b. int w, t, h = 0;
c. int d = 0;
d. int a, b = 8, c = 19;
e. char ch = 10;
3.
What is the final value of X after the following code is executed?
(Points: 0.5)
int X;
X = 10;
X = X + 1;
X++;
X = X - 5;
X--;
a. 11
b. 10
c. 12
d. 6
e. 5
4. What is the final value of A after the following code is executed?
double A = 100.345;
int Y = 1;
float Z = 2.0F;
Z = Z + Y;
A = A + Z;
a. 103.345
b. 100.345
c. 97.345
d. 101.345
5.
What will be the final value of Z after the following code is executed?
float Z = 0.0F;
Z = 1 + 2 * 3 / 2;
a. 4.5
b. 3.5
c. 4.0
d. 0.0
6. What is the value for z after the code is executed?
int x = 5;
int y = 2;
float z = 0.0F;
z = x / y;
a. 2.5
b. 0
c. 2
d. Error
7. What is the final value of B after the following code is executed?
int B = 3;
B = B + 1;
B++;
++B;
a. 3
b. 4
c. 6
d. 5
8. Which of the following is not a correct way to comment code?
(Points: 0.5)
a. /* A comment */
b. // A comment
c. /* A Comment
d. // A Comment //
9. What is the final value of x after the following code is executed?
int x = 0;
int y = 10;
x = y % 2;
a. 0
b. 10
c. 5
d. 1
10. What will be printed after executing the following code?
(Points: 0.5)
int x = 5;
int y = 1;
x = x + 1;
/*
y = y + 1;
*/
x = y;
Console.WriteLine("x is " + x);
a. x is 5
b. x is 1
c. x is 7
d. x is y
cheers.
6 replies to this topic
#1
Posted 01 April 2010 - 04:11 AM
|
|
|
#2
Posted 01 April 2010 - 04:27 AM
This Forum is not here so that we can do your school work for you. Especially if that school work is a quiz. If you have questions on homework you are more than welcome to ask for help and show us the code that you are currently working on and we will help you debug it. DO NOT JUST POST SOMETHING AND ASK US FOR THE ANSWER.
FORUM != PRIVATE_TUTOR
FORUM != PRIVATE_TUTOR
While( !User.hasAnswer )
{
User.askQuestion();
if( User.postCode && User.putForthEffort )
{
CodeCallMembers.Help();
User.hasAnswer = true;
}
else
{
CodeCallMembers.Laugh();
}
}
-CDG10620
Software Developer
Software Developer
#3
Posted 01 April 2010 - 01:32 PM
Bahahaha! That's awesome, cdg. #2 looks bogus to me since there isn't a correct answer...at least in c++. Would there be a correct answer in another language maybe?
Edited by cod3b3ast, 01 April 2010 - 01:37 PM.
Had more to say
I don't document code. If it was hard to write, it should be hard to read ;)
#4
Posted 01 April 2010 - 02:57 PM
#5 is a trick question. The actual answer (3.0) is not provided. Why? because 3/2 is integer division and the result is 1. 1+2*1 = 3
#10: >> Console.WriteLine("x is " + x);
That is not C or C++ code. Looks more like managed c++ (CLR), which is different than standard c++.
I think your teacher needs to proofread, test, and proofread again the test questions. Two of them (2 and 5) and invalid.
#10: >> Console.WriteLine("x is " + x);
That is not C or C++ code. Looks more like managed c++ (CLR), which is different than standard c++.
I think your teacher needs to proofread, test, and proofread again the test questions. Two of them (2 and 5) and invalid.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#5
Posted 01 April 2010 - 03:13 PM
Actually, #5 is valid because of order of operation. The multiplication is done before the division, so it works out to being (1 + (2*3) / 2) which is 4. You are right about the teacher though; he/she needs to do a little debugging on her tests before just throwing them out there, hoping nobody will notice.
I don't document code. If it was hard to write, it should be hard to read ;)
#6
Posted 01 April 2010 - 03:22 PM
cod3b3ast said:
Actually, #5 is valid because of order of operation. The multiplication is done before the division, so it works out to being (1 + (2*3) / 2) which is 4. You are right about the teacher though; he/she needs to do a little debugging on her tests before just throwing them out there, hoping nobody will notice.
I knew that -- was just testing to see if anyone else did too :thumbup:
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#7
Posted 02 April 2010 - 05:11 PM
Ha! Touche ;)
I don't document code. If it was hard to write, it should be hard to read ;)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









