469,317 Members | 1,985 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

Code Comprehension Exercise

Code Comprehension Exercise

Read the following code carefully before answering the questions.

unsigned long normalise(unsigned long input_time)
{

bool finished;

// This produces a formatted time string like:
// Thu_Nov_24_18:22:48_1986
string str_time = format_time( input_time );

while( str_time.substr(1,3) != "Sun")
{
input_time -= 24*60*60;
str_time = format_time( input_time );
}

while( str_time.substr(11,2) != "00" )
{
input_time -= 60*60;
str_time = format_time( input_time );
}

while( str_time.substr(14,2) != "00")
{
str_time = format_time( input_time );
input_time -= 60;
}

while( str_time.substr(17,2) != "00")
{
input_time -= 1;
str_time = format_time( input_time );
}

return input_time;
}

1) Briefly explain what you think the overall purpose of this function is (do not describe each line of code).

2) There are two bugs in this code that prevent it from functioning correctly; circle them.

3) What would actually happen when this code is run?

(a) as originally written?
(b) with the first bug fixed?

4) Discuss the efficiency of the code assuming the bugs have been fixed.

5) Given that input_time actually represents an integer value in seconds since the epoch and has the value 0 at precisely "Thu Jan 1 00:00:00 1970", write
May 2 '07 #1
2 3735
debasisdas
8,127 Expert 4TB
Is it part of Oracle SQL,pl/sql ???
May 3 '07 #2
Is it part of Oracle SQL,pl/sql ???
this is the part of pl/sql.

if you know how to solve this then please help me.

Thank you
May 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by jsaul | last post: by
35 posts views Thread by Moosebumps | last post: by
9 posts views Thread by cyberscout | last post: by
9 posts views Thread by falcon | last post: by
18 posts views Thread by a | last post: by
4 posts views Thread by Gregory Guthrie | last post: by
14 posts views Thread by Ben | last post: by
6 posts views Thread by mh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.