473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 3982
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

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

Similar topics

14
by: jsaul | last post by:
Hi there, wouldn't it be useful to have a 'while' conditional in addition to 'if' in list comprehensions? foo = for i in bar: if len(i) == 0: break foo.append(i)
35
by: Moosebumps | last post by:
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you...
7
by: Chris P. | last post by:
Hi. I've made a program that logs onto a telnet server, enters a command, and then creates a list of useful information out of the information that is dumped to the screen as a result of the...
9
by: cyberscout | last post by:
OK I have some code which I didn't write and I'm toying with whether I need to tidy it up. In the code is the line shown in Example 1 Exampe 1: sprintf(stringvariable, "%s", "String"); ...
9
by: falcon | last post by:
Is there a way I can do time series calculation, such as a moving average in list comprehension syntax? I'm new to python but it looks like list comprehension's 'head' can only work at a value at...
18
by: a | last post by:
can someone tell me how to use them thanks
4
by: Gregory Guthrie | last post by:
Sorry for a simple question- but I don't understand how to parse this use of a list comprehension. The "or" clauses are odd to me. It also seems like it is being overly clever (?) in using a...
14
by: Ben | last post by:
I have recently learned how list comprehension works and am finding it extremely cool. I am worried, however, that I may be stuffing it into places that it does not belong. What's the most...
6
by: mh | last post by:
I googled and wiki'ed, but couldn't find a concise clear answer as to how python "list comprehensions" got their name. Who picked the name? What was the direct inspiration, another language? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.