Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 21st, 2008, 05:03 PM
WBW87 WBW87 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 WBW87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 13 sec
Reputation Power: 0
Help with finished test

I am took this online assignment but it won't tell me what the right answers I missed are. Its really bugging me, It said I missed some but wont tell me what. Could you tell me what I missed and what the right answer is? I put an x by my answers.

1. What type must a variable be if you want to store the number 9.8987 in it?

Xdouble
char
int
bool


2. What is the proper way of declaring and initializing a variable in the same line?

a=int; a = 10;
a=10 int;
X int a=10;
it is not possible


3. What is the value of the variable result after the execution of the following code segment?
int a=2, b=2, c=6, result;
result = a * b + a + c / 2;

8
6
10
X9


4. If two arithmetic operators in an expression have the same precedence, they work according to their:

prioritizing factor
X associativity
data types
maximun numbers


5. Which of the following is not a valid boolean expression.?

(1 < x < 100)
(x != 1) && (y !=10)
(x >= 5) && (x<=50)
X (x ==y)


6. Which of the following operators has the highest precedence?

*
&&
X ( )
+=


7. What is the value of result variable after the execution of the following code segment:
int a = 8;
int b = 9;
int c = 0;
int result=100;
if (a != b && c == 0 ) result++;
else --result;

99
100
0
X101

8. Which of the loop statements is ideal for situations that require a counter

The do-while loop
X The for loop
Nested loops
The while loop


9. Convert the following while loop to a for loop

a = 8; sum=0;
while ( a > 0 ) { sum = sum + a; a= a - 1; }



for (a=8; sum=0 ; a > 0; a--) sum ++;
for (a=8, sum =0 ; a > 0; a--) sum += a;
X for (a=8; sum=0 ; a > 0; a=a-1) sum + a;
for (a=8, sum =0 ; a < 0; a--) sum += a;


10. How many times will the value in the variable tmp be displayed in the following program segment? (assume output displays the value of the variable).

int x, y, z; int tmp=0;
for (x=0; x<2; x++)
for (y=0; y<2; y++)
for (z=0; z<2; z++) output (tmp);

0
2
6
X 8


11. What is the value of the variable result after the execution of the following code segment?

a = 5; result=10;
while ( a++ < 10 ) { result ++; }

15
X 14
16
10


12. What is the value of the variable result after the following switch statement?

int result=0;
int option=1;
switch (option) {
case 0: result=result+1;
case 1: result=result+2;
case 2: result=result+3;
}

1
X 2
3
5



13. What is the output after the following for statement? (assume output displays the value of the variable).

for (int i=0; i<10; i++) {
if (i>=2 && i<=6) continue;
else output ( i );
}

1 2 3 4 5 6 7 8 9
0 1 7 8 9
X 0 1 2 6 7 8 9
2 3 4 5 6

14. The _________ statement causes a loop to terminate immediately.

continue
quit
X break
end loop


15. After declaring an array of 5 integers, what is the output of the following code segment:? (assume output displays the value of the variable)

for (int i = 0; i < 5; i++) {
array[i] = i * i ;
}
output (array[3] );

2
3
4
X 9

16.Function getValue has ____ parameter(s) and its return type is _____

double getValue (int x, float y) {
/* body of the function*/
}

X 2, double
1, int
1, float
2, void

17. The keyword _______ indicates that a function/method does not return a value.

nokey
return
X void
exit

18. What is the output of the following segment code after calling the function/method display ?

void disp ( ) {
int i=10;
duplicate ( i );
output(i);
}
static void duplicate (int i) {
i=i*2;
}

0
10
20
X syntax error


19. The scope of a _______ variable starts from its declaration and continues to the end of the block that contains the variable

static
X local
global
public

20. When passing an array as an argument to a function, the funtion __________

X will pass it by value
cannot modify the original array
can modify the original array
will create a new version of the array

Reply With Quote
  #2  
Old May 23rd, 2008, 03:32 PM
ReeVee ReeVee is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 37 ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level)ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level)ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level)ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level)ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level)ReeVee User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 16 h 29 m 50 sec
Reputation Power: 23
I can not say that this is 100% as it has been some time since I have done C or C++ but here are the ones that I have different answers for and what I thing they should be

5. 1
9. 2
11. 1
13. 2
18. 3
20. 3

Reply With Quote
  #3  
Old May 24th, 2008, 10:37 AM
WBW87 WBW87 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 WBW87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 13 sec
Reputation Power: 0
Thanks so much

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Help with finished test


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway