By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,333 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,333 IT Pros & Developers. It's quick & easy.

Help with a C program

P: n/a
SK
Hi
I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office. Anyhow, I amhoping
that the porblem I am having is simple to those much more experienced
in programming. I am trying to use the concept of arrays to calculate
the hours of my backoffice staff, however I am getting a ridiculous
amount of error lines. If any one has time to help me that would be
great. I am using the free devc++ compiler.
Thanks in advance to anyone who offers some advice.
SK
//Specs to be added later

//C Libraries
#include <stdio.h>
#include <math.h>
#include <string.h>
//Global Constants
# define FULLNAME[20]
# define EMPLOYEES[1000]

/*Define the structure.*/
struct EMP_WeeklyPay
{
char first_name[FULLNAME];
char last_name[FULLNAME];
float RegHr;
float wage;
float OTHr;
float OTHrPay;
float GrossPay;
}
/*Rename the structure syntax.*/
typedef EMP_WeeklyPay EWP;
/*Create an array of structures.*/
EWP emp[EMPLOYEES];

/*Counters*/
int n, numemp;
int count = 0;

/*Strings in input*/
char department[20], fn[FULLNAME], ln[FULLNAME], char again;

/*temporary float*/
float wage, float OTwage, float hours, float RegHr,
float OTHrPay, float OTHr, float GrossPay;
printf("\n\nMountain Pacific Corporation\n");
printf("Department Salary Program\n\n");
printf("Please enter the name of the department: ");
scanf("%s", department);
/*Loop to read in employee wage data*/
for (n = 0; n < EMPLOYEES; ++n){

printf("\nEnter employee # %d: ", count_EMP);
scanf("%s %s", &Fname, &Lname);

printf("\nPlease enter the hourly wage for the employee:
");
scanf("%f", &wage);

printf("\nPlease enter the number of hours worked this"
" week: ");
scanf("%f", &hours);

printf("\nThank you. Process another employee?");
scanf("%s", &again);

}
/*Read in the input*/
numemp = scanf("%11s%11s%f%f%f%f%f", fn, ln, &RegHr,
&wage, &OTHr, &OTHrPay, &GrossPay);
/*Check if user is done*/
printf("\nThank you. Process another employee?");
scanf("%s", &again);

while(again == 'Y' || again == 'y');

if(again != 'Y' && again !='y');
printf("End of processing\n\n\n");
/*Process the input*/
if(num == 7)
{

if (RegHr > 40)
{
OTHr = hours - 40;
OTHrPay = OT * OTHr * wage;
RegHrPay = 40.0 * wage;
}

else
{
RegHrPay = hours * wage;
OTHrPay = 0.0;

}

GrossPay = RegHrPay + OTHrPay;

strncpy(employee[n].first_name, fn, FULLNAME-1);
employee[n].first_name[FULLNAME-1] = '\0';

strncpy(employee[n].last_name, ln, FULLNAME-1);
employee[n].last_name[FULLNAME-1] = '\0';

employee[n].regularhours = RegHr;
employee[n].wage = wage;
employee[n].overtimehours = OTHr;
employee[n].overtimepay = OTHrPay;
employee[n].GrossPay. = GrossPay;
++count;
}

/*Print Table*/

printf("\n\nMountain Pacific Corporation\n");
printf("Department Salary Program\n\n");

printf("Employee Reg Hrs "
"Overtime Hrs Gross\n");

printf("-----------------------------------------"
"-------------------------\n\n");


for(n=0; n < count; ++n) {
printf("%-35s%-17s%12f%10f%12f%10f%%5f",
employee[n].first_name,
employee[n].last_name, employee[n].RegHr,
employee[n].wage, employee[n].OTHr, employee[n].OTHrPay,
employee[n].GrossPay);
}
}

Nov 15 '05 #1
Share this Question
Share on Google+
27 Replies


P: n/a
On 13 Nov 2005 00:29:53 -0800, "SK" <ba******@aol.com> wrote in
comp.lang.c:
Hi
First things first, good manners. Don't post the same message
separately to different groups. If you are sure it belongs in more
than one group, cross-post it.
I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office. Anyhow, I amhoping
that the porblem I am having is simple to those much more experienced
in programming. I am trying to use the concept of arrays to calculate
the hours of my backoffice staff, however I am getting a ridiculous
amount of error lines. If any one has time to help me that would be
great. I am using the free devc++ compiler.
Thanks in advance to anyone who offers some advice.
SK
//Specs to be added later

//C Libraries
#include <stdio.h>
#include <math.h>
#include <string.h>
//Global Constants
# define FULLNAME[20]
# define EMPLOYEES[1000]


"Doctor, it hurts when I do this!"

"Then don't do it."

Please provide your instructor's email address and we'll send you
completed assignment directly.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 15 '05 #2

P: n/a
On 13 Nov 2005 00:29:53 -0800, in comp.lang.c , "SK"
<ba******@aol.com> wrote:
//Global Constants
# define FULLNAME[20]
# define EMPLOYEES[1000]
I assume you're trying to create a constant FULLNAME with value 20.
#define FULLNAME 20
/*temporary float*/
float wage, float OTwage, float hours, float RegHr,
float OTHrPay, float OTHr, float GrossPay;
Strongly recommend you don't use floats for any mathematical
calculations. They're not accurate enough in most cases.
scanf("%f", &wage);
Strongly recommend you don't use scanf. To explore why, try typing in
unexpected things such as "two thousand", nothing at all, etc.

fgets() is a much safer function. You can sscanf the string
afterwards.

printf("\nPlease enter the number of hours worked this"
" week: ");
scanf("%f", &hours);

printf("\nThank you. Process another employee?");
Don't you need to do someething with wage and hours before you process
the next employee? Store them perhaps?
scanf("%s", &again);
}
/*Read in the input*/ You didn't prompt the user for any input - he won't know what to
type...
while(again == 'Y' || again == 'y');


whats this while doing here? There should be a do somewhere

do {
// stuff
while(condition);
at this point, "core dumped, too many errors, correct those ones and
try again"....
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 15 '05 #3

P: n/a
Jack Klein wrote:

On 13 Nov 2005 00:29:53 -0800, "SK" <ba******@aol.com> wrote in
comp.lang.c:
I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office.

Please provide your instructor's email address and we'll send you
completed assignment directly.


I wonder if the assignment was stated as
"You are a physician, and hoping ..."?

--
pete
Nov 15 '05 #4

P: n/a
SK said:
Hi
I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office. Anyhow, I amhoping
that the porblem
I believe you. Your spelling is bad enough that you could well be a doctor.
Please understand, however, that you won't be in a position to write good
programs until you've been a programmer for much longer than you were in
medical school.
I am having is simple to those much more experienced
in programming. I am trying to use the concept of arrays to calculate
the hours of my backoffice staff, however I am getting a ridiculous
amount of error lines.


Use a spreadsheet. Or an accounts package. You'll find it much simpler than
writing a C program, and much quicker, and less error-prone. By all means
learn C, but don't do so using "live" data such as staff hours. That's just
plain daft.

After a few years of diligent plugging away on your programming, you'll
possibly be in a position to write a real payroll program in C. But by that
point, you won't want to, because there's much more excitement involved in
writing new programs than in writing programs other people have already
written.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #5

P: n/a
Richard Heathfield wrote:
SK said:

Hi
I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office. Anyhow, I amhoping
that the porblem

I believe you. Your spelling is bad enough that you could well be a doctor.
Please understand, however, that you won't be in a position to write good
programs until you've been a programmer for much longer than you were in
medical school.

You're laying it on a little thick. Your statements also imply that
becoming a good programmer is harder than becoming a good doctor, a
statement I doubt you are qualified to make, unless indeed you are
experienced in both -- but then I would have expected you to mention that.

There's also the fact that writing "good" programs is not half as hard
as it's made out to be. Writing good programs that meet challenging
requirements is; likewise, writing good programs when you're used to
writing bad ones.

<snip> After a few years of diligent plugging away on your programming, you'll
possibly be in a position to write a real payroll program in C. But by that
point, you won't want to, because there's much more excitement involved in
writing new programs than in writing programs other people have already
written.


If you get to be so lucky to do that in the first place, as opposed to
just having to *maintain* programs other people have written, which is
by far the most common and unrewarding kind of job for programmers...
but that's another story.

S.
Nov 15 '05 #6

P: n/a
Skarmander said:
Richard Heathfield wrote:
Please understand, however, that you won't be in a position to
write good programs until you've been a programmer for much longer than
you were in medical school.
You're laying it on a little thick.


I don't think so. What I said is, I think, accurate.
Your statements also imply that
becoming a good programmer is harder than becoming a good doctor,
I didn't actually mention "good doctor" at all.
a
statement I doubt you are qualified to make, unless indeed you are
experienced in both -- but then I would have expected you to mention that.
Well, I'm not a doctor. But in fact programming is vastly more complicated
than general medical practice. The doctor has just one (admittedly very
complex) system to worry about, and he can devote years to studying just
that one system. The programmer has to deal with a great many complex
systems at many different levels of abstraction - far more than the doctor
will ever face. (It is normally the case, however, that the stakes are
higher for doctors, since a mistake can cost a patient's life; whilst some
programmers do deal with safety-critical systems, this tends to be the
exception rather than the rule.)
There's also the fact that writing "good" programs is not half as hard
as it's made out to be.
Hmmm. You'd think people would be able to write "Hello, world", wouldn't
you? Most C programmers I encounter can't do this without my being able to
find at least one hole to pick, and usually several.

Writing good programs that meet challenging
requirements is;


Agreed - but I think you'll find that most people find even non-challenging
programs hard to write well.
because there's much more excitement
involved in writing new programs than in writing programs other people
have already written.


If you get to be so lucky to do that in the first place, as opposed to
just having to *maintain* programs other people have written, which is
by far the most common and unrewarding kind of job for programmers...


I don't think the OP intends to seek employment in the programming field, so
I don't suppose this applies to him.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #7

P: n/a
In article <dl**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invalid.invalid> wrote:
[OT]
Well, I'm not a doctor. But in fact programming is vastly more complicated
than general medical practice. The doctor has just one (admittedly very
complex) system to worry about, and he can devote years to studying just
that one system. The programmer has to deal with a great many complex
systems at many different levels of abstraction - far more than the doctor
will ever face.


I came across an appropriate quotation on this a few days ago:

"If physicians would read two articles per day out of the
six million medical articles published annually, in one year,
they would fall 82 centuries behind in their reading."

-- Miser WF, Critical Appraisal of the Literature,
J Am Board Fam Pract., 12(4):315-333, 1999

--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Nov 15 '05 #8

P: n/a
Richard Heathfield wrote:
What I said is, I think, accurate.


Even this?: "I believe you."

LOL!

Handwriting, is what doctors are notorious for.

Results 1 - 10 of about 12,800 for "doctor's handwriting".
Results 1 - 10 of about 45 for "doctor's spelling". (0.78 seconds)

--
pete
Nov 15 '05 #9

P: n/a
Richard Heathfield wrote:
Skarmander said:
I'll mark it OT now for the benefit of people who like to ignore these
things before reading them, though I'm not apologetic about posting
them. :-)
Richard Heathfield wrote:
Please understand, however, that you won't be in a position to
write good programs until you've been a programmer for much longer than
you were in medical school.


You're laying it on a little thick.

I don't think so. What I said is, I think, accurate.
Your statements also imply that
becoming a good programmer is harder than becoming a good doctor,

I didn't actually mention "good doctor" at all.

Hence my use of "imply". Though "allude to" might have been preferable.
Given the rest of your reply, the general sentiment does seem to be that.
a
statement I doubt you are qualified to make, unless indeed you are
experienced in both -- but then I would have expected you to mention that.

Well, I'm not a doctor. But in fact programming is vastly more complicated
than general medical practice. The doctor has just one (admittedly very
complex) system to worry about, and he can devote years to studying just
that one system. The programmer has to deal with a great many complex
systems at many different levels of abstraction - far more than the doctor
will ever face.


This also ignores that the complexity programmer's face is man-made, and
nearly always reflects human thought processes at one step or
another. To a very large extent, we have only ourselves to blame when we
are mired in "a great many complex systems at many different levels of
abstraction" -- and those levels of abstraction, might I add, were
designed to *solve* problems of complexity.

Software is so complex because there are (almost) no physical laws
restraining us; only we can prevent things from spiraling out of
control, by doing the restraining ourselves.

In this sense, comparing the complexity of medicine with that of
programming is not easy. Some parallels can be drawn, but the ultimate
applications of either field will mean some things will never compare well.

Programmers in *particular* should be wary of thinking they are more
versed in understanding and mastering complexity better than other
professions, because they themselves create much of the complexity in
their own field, and thus cannot escape a certain cognitive bias.
(It is normally the case, however, that the stakes are higher for
doctors, since a mistake can cost a patient's life; whilst some
programmers do deal with safety-critical systems, this tends to be
the exception rather than the rule.)

Yes, this is another factor that complicates comparison. I have never
run the risk of killing someone because I made an off-by-one error in a
loop (notwithstanding that a small number of programmers no doubt have);
consequently, while I of course try to do everything to avoid making
such a mistake, I would not give it such a high priority that it
drastically reduces overal effectiveness (however this is defined in
practice).

Doctors had better give some things very unreasonable priorities under
all circumstances, from a programmer's point of view, because they don't
get to restore things from backups. This skews standard operating
procedures somewhat.
There's also the fact that writing "good" programs is not half as hard
as it's made out to be.

Hmmm. You'd think people would be able to write "Hello, world", wouldn't
you? Most C programmers I encounter can't do this without my being able to
find at least one hole to pick, and usually several.

Really? Of the "ha ha, you used void main()" kind? "Hello, world" is the
archetypical example where it's not essentially possible to commit a
design error, because the thing to be done is practically an atomic
operation.

I'd say these errors occur because the C programmers in question are not
sufficiently enamored with the complexities of C. If they were, they
would see them as natural. Try to imagine someone making a mistake in
"Hello, world" in Python -- this would reduce to one's ability to read
and type, which, while essential, don't exactly seem to be
representative of a programmer's skill set.

Whether this reflects on programmers as they program or as how they
construct their tools is another matter. I think that as an illustration
of how programming is tough it's rather poor, because it's exactly the
kind of "single complex system" knowledge doctors (and programmers)
should find so easy to master.
Writing good programs that meet challenging
requirements is;

Agreed - but I think you'll find that most people find even non-challenging
programs hard to write well.


This is because the restrictions put into place to manage the complexity
of programming usually allow one to write bad code quickly, and with a
modicum of functionality. That in turn encourages the "make a rough
draft and tweak until it appears to work" approach, which most tools in
fact support and promote, even though it's antithetical to the very
nature of programming (but very compatible with common human thought
processes, and catered to for this very reason).

Programming is not a game of Mastermind, but the way that it's taught
and promoted often allows people to pick up unproductive mental
roadblocks. We could also go for "people are stupid", but that will only
take you so far. (Even though we all know it's true.)

There is also, of course, always a minimum of natural aptitude needed to
master any field; it is true that not any person could just become a
doctor, no more than anyone would be qualified to program a computer if
they just studied long enough. But if good programmers are rarer than
good doctors (and I doubt this, though it's impossible to quantify),
this wouldn't necessarily imply programming is harder in an objective
sense, only that less people are suitable for it.

It is true that the challenge of programming lies not in mastering the
languages or the tools or the systems that are given, even though these
are important practical skills; they lie in cultivating effective
thought processes. Changing the way you think is one of the most
difficult things to do, and programming typically requires a lot of it.
Perhaps it is this that would truly allow us to claim a greater
difficulty factor for programming than most other things.

S.
Nov 15 '05 #10

P: n/a
pete said:
Richard Heathfield wrote:
What I said is, I think, accurate.


Even this?: "I believe you."

LOL!

Handwriting, is what doctors are notorious for.


Oops. Touche'. Note, however, that I have never yet met a doctor who could
spell. Some have even got my name wrong, despite having a correct template
from which to copy.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #11

P: n/a
Skarmander said:
Richard Heathfield wrote:

Well, I'm not a doctor. But in fact programming is vastly more
complicated than general medical practice. The doctor has just one
(admittedly very complex) system to worry about, and he can devote years
to studying just that one system. The programmer has to deal with a great
many complex systems at many different levels of abstraction - far more
than the doctor will ever face.
This also ignores that the complexity programmer's face is man-made,


No, it doesn't. The source of the complexity is irrelevant to the person who
has to deal with that complexity. It doesn't matter, from a doctor's point
of view, whether God invented the human body or whether it's a chance
collection of enzymes and cells - he still has to deal with the reality of
its current state. Same for programmers. And computer systems can be way
more complex than human beings (except, perhaps, for the brain, but the
doctor doesn't really know how to deal with that anyway, except for
chopping bits out on special occasions).
Software is so complex because there are (almost) no physical laws
restraining us; only we can prevent things from spiraling out of
control, by doing the restraining ourselves.
Yeah, and we don't, which is why programmers have such a rough time. It
doesn't particularly help the situation that programming is a creative
discipline, and creative people do so love to create stuff!

In this sense, comparing the complexity of medicine with that of
programming is not easy. Some parallels can be drawn, but the ultimate
applications of either field will mean some things will never compare
well.

Programmers in *particular* should be wary of thinking they are more
versed in understanding and mastering complexity better than other
professions, because they themselves create much of the complexity in
their own field, and thus cannot escape a certain cognitive bias.
The cognitive bias is inevitable. We know what we do, and we know what we're
doing. The source of the complexity is irrelevant, and in any case most of
the complexity I face is not complexity I created myself, but complexity
created by other programmers. So the fact that *a* human created it is no
consolation, since it wasn't *this* human that created it.
Doctors had better give some things very unreasonable priorities under
all circumstances, from a programmer's point of view, because they don't
get to restore things from backups. This skews standard operating
procedures somewhat.

(Ring ring, ring ring, ring ring...)

D: Hello?
W: Is that the doctor?
D: Yes, Mrs Wilson, how can I help?
W: It's my husband. I brought him his morning cup of coffee, but he won't
wake up!
D: Hmmm. Fresh or instant?
W: Instant.
D: Do you have any fresh?
W: No.
D: Okay. Could you please bring him his morning cup of coffee again? And
just tell me what happens.
(pause - over the phone, the doctor can just hear "Darling? Darling? Wake
up!")
W: No, he's not responding at all.
D: Okay. We're going to try a little experiment. I'd like you to put on your
wellies or some Doc Martens or something, climb up onto the bed, and give
him a good kicking.
W: Um, is that a good idea?
D: Trust me, I'm a doctor.
W: Okay.
(pause - over the phone, various grunting noises can be heard)
W: Well, I've done that.
D: Okay. Now try the coffee again.
W: Still no response.
D: Oh dear. Tell me, when you acquired your husband, did you happen to
receive a CD-ROM at the same time?
There's also the fact that writing "good" programs is not half as hard
as it's made out to be.


Hmmm. You'd think people would be able to write "Hello, world", wouldn't
you? Most C programmers I encounter can't do this without my being able
to find at least one hole to pick, and usually several.

Really? Of the "ha ha, you used void main()" kind? "Hello, world" is the
archetypical example where it's not essentially possible to commit a
design error, because the thing to be done is practically an atomic
operation.


Well, I don't normally laugh at them unless there's a good reason (e.g. "I
want to"), but yeah, that's what I mean. The thing is, if we can't write
"Hello, world" without at least giving people cause for comment, what
chance have we of writing a "real" program properly? The problem, I think,
is that we don't treat the writing of software seriously enough. Because we
can cobble something together and it'll sort of work, kinda, we say "fine,
that's done, now on to the next thing", and the engineering quality is -
well, not zero, but pretty low.
Agreed - but I think you'll find that most people find even
non-challenging programs hard to write well.


This is because the restrictions put into place to manage the complexity
of programming usually allow one to write bad code quickly, and with a
modicum of functionality. That in turn encourages the "make a rough
draft and tweak until it appears to work" approach, which most tools in
fact support and promote, even though it's antithetical to the very
nature of programming (but very compatible with common human thought
processes, and catered to for this very reason).


Um, precisely. If I'd read that before, I could have saved myself a
paragraph!
It is true that the challenge of programming lies not in mastering the
languages or the tools or the systems that are given, even though these
are important practical skills; they lie in cultivating effective
thought processes. Changing the way you think is one of the most
difficult things to do, and programming typically requires a lot of it.


And, alas, it is not just difficult but extremely rare. I was once asked
whether I knew how to play a particular rock song on guitar. I thought I
did, but I played a particular section in 4/4 (no, that's not a fraction,
just a notational convenience), and my expert guitarist friend shook his
head and said, "no, that's not it". I said, "well, how should it be played
then?" He answered, "it's no good - you've learned to play it in 4/4, so
you'll never be able to adapt to 7/8, which is what it should be". So I
played that section again, this time in 7/8. He was somewhat appalled with
the ease with which I could do it. (No, I'm not a terribly good guitarist -
but I do know how to count up to 7!) People are not, generally speaking,
good at adapting, once they've invested a certain amount of effort in
learning to do - or think - things in a particular way.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #12

P: n/a
Richard Heathfield wrote:
Skarmander said:

Richard Heathfield wrote:
Well, I'm not a doctor. But in fact programming is vastly more
complicated than general medical practice. The doctor has just one
(admittedly very complex) system to worry about, and he can devote years
to studying just that one system. The programmer has to deal with a great
many complex systems at many different levels of abstraction - far more
than the doctor will ever face.
This also ignores that the complexity programmer's face is man-made,

No, it doesn't. The source of the complexity is irrelevant to the person who
has to deal with that complexity. It doesn't matter, from a doctor's point
of view, whether God invented the human body or whether it's a chance
collection of enzymes and cells - he still has to deal with the reality of
its current state.


You're missing my point. It matters where the complexity came from
insofar as this dictates the nature of the complexity. A program and the
human body may both be complex, but they're complex in different ways,
and it's not just a difference in how many layers of abstraction there are.

In this sense it *would* matter if "God invented the human body", if we
approximately knew how God thought. (For a naturalistic explanation, we
can substitute "how evolution has worked over the years", which is
likely to be almost as unfathomable.) No matter how complicated and
bizarre a program seems to us, at the far end, eventually, some human
being thought up some abstraction of the code you're looking at now.
This may not help you much in individual cases, but it's something you
implicitly rely on.

Doctors would not get very far, in turn, if they implicitly relied on a
working model of God's mind.
Same for programmers. And computer systems can be way
more complex than human beings (except, perhaps, for the brain, but the
doctor doesn't really know how to deal with that anyway, except for
chopping bits out on special occasions).
You have an almost disdainful idea of the complexity of the human body.
If a computer system is way more complex than a human body, something is
terribly wrong. You think you know complexity when you hear about
millions of lines of code, but a computer program is a child's toy
compared to a genetic blueprint, and tracking a core dump of a running
system to an obscure bug in an ill-understood module is a trivial
exercise compared to determining the root cause of a disease.

What may be accurate (and I really can't tell) is that the complexity of
a human body from the doctor's (or even specialist's) point of view may
be "relatively simple" compared to the actual complexity of the system
as a whole (i.e. he doesn't worry about enzyme folding or mitochondria
but whether it "hurts when I do this"). At *that* level we may perhaps
compare doctors and programmers, but we will probably find out more
about how effective humans can organize complexity than about the actual
measure of complexity involved -- intuitively speaking, since an
objective measure of complexity is a tricky thing.
Software is so complex because there are (almost) no physical laws
restraining us; only we can prevent things from spiraling out of
control, by doing the restraining ourselves.

Yeah, and we don't, which is why programmers have such a rough time. It
doesn't particularly help the situation that programming is a creative
discipline, and creative people do so love to create stuff!

Programmers are like jazz musicians, except that for jazz musicians, it
works.
The source of the complexity is irrelevant, and in any case most of
the complexity I face is not complexity I created myself, but
complexity created by other programmers. So the fact that *a* human
created it is no consolation, since it wasn't *this* human that
created it.

But you do realize how this is a self-perpetuating situation?
Programming is complex because people make it complex, and they're not
overly concerned with simplifying it because everyone has to be smart
enough to deal with someone else's complexity anyway. It's almost the
programmer's equivalent of the Peter principle.

If programmers then point out that programming is so tough and how
nobody is really to blame individually, should we sympathize with them
or mock them? Perhaps both -- but they should be none too eager to draw
this kind of attention.
Doctors had better give some things very unreasonable priorities under
all circumstances, from a programmer's point of view, because they don't
get to restore things from backups. This skews standard operating
procedures somewhat.

[section that could be called "what if doctors were tech support"]

Great stuff. :-)

<snip> Um, precisely. If I'd read that before, I could have saved myself a
paragraph!
It can be annoying to discuss things with people who agree with you...

<snip> People are not, generally speaking, good at adapting, once they've
invested a certain amount of effort in learning to do - or think -
things in a particular way.


"Nothing so needs reforming as other people's habits", as Mark Twain put
it...

S.
Nov 15 '05 #13

P: n/a

Richard Heathfield wrote:
(Ring ring, ring ring, ring ring...)

D: Hello?
W: Is that the doctor?
D: Yes, Mrs Wilson, how can I help?
W: It's my husband. I brought him his morning cup of coffee, but he won't
wake up!
D: Hmmm. Fresh or instant?
W: Instant.
D: Do you have any fresh?
W: No.
D: Okay. Could you please bring him his morning cup of coffee again? And
just tell me what happens.
(pause - over the phone, the doctor can just hear "Darling? Darling? Wake
up!")
W: No, he's not responding at all.
D: Okay. We're going to try a little experiment. I'd like you to put on your
wellies or some Doc Martens or something, climb up onto the bed, and give
him a good kicking.
W: Um, is that a good idea?
D: Trust me, I'm a doctor.
W: Okay.
(pause - over the phone, various grunting noises can be heard)
W: Well, I've done that.
D: Okay. Now try the coffee again.
W: Still no response.
D: Oh dear. Tell me, when you acquired your husband, did you happen to
receive a CD-ROM at the same time?

This made reading this OT thread worth it.

Nov 15 '05 #14

P: n/a
Skarmander wrote:
[snip]
Perhaps it is this that would truly allow us to claim a greater
difficulty factor for programming than most other things.


One question:

Did you type while using one or both hands?
Regards,

Steve

Nov 15 '05 #15

P: n/a
Steve wrote:
Skarmander wrote:
[snip]
Perhaps it is this that would truly allow us to claim a greater
difficulty factor for programming than most other things.

One question:

Did you type while using one or both hands?


Oh, sorry, I forgot.

"But what the fuck do I know, I'm just this guy. And English isn't my
native language."

Both hands, definitely. But I *do* like sounding like a pompous ass.

S.
Nov 15 '05 #16

P: n/a
Skarmander wrote:
Steve wrote:
Skarmander wrote:
[snip]
Perhaps it is this that would truly allow us to claim a greater
difficulty factor for programming than most other things.


One question:

Did you type while using one or both hands?


Oh, sorry, I forgot.

"But what the fuck do I know, I'm just this guy. And English isn't my
native language."

Both hands, definitely. But I *do* like sounding like a pompous ass.


Just checking. I just fell off the turnip truck and I'm not always
sure how I should take some posters. I stand corrected.
Regards,

Steve

Nov 15 '05 #17

P: n/a
Skarmander said:
You have an almost disdainful idea of the complexity of the human body.
Actually, I think the design of the human body is astoundingly clever.
If a computer system is way more complex than a human body, something is
terribly wrong.
Then something is terribly wrong.
You think you know complexity when you hear about
millions of lines of code, but a computer program is a child's toy
compared to a genetic blueprint,
Oops, paradigm clash. How many GPs do genetics research as part of their
daily work? I thought we were talking about doctors, not propeller-heads.
and tracking a core dump of a running
system to an obscure bug in an ill-understood module is a trivial
exercise compared to determining the root cause of a disease.
"Mrs Wilson, I think your husband has sleepitis. Just on the off-chance that
I'm right, get him to take these pills twice a day, and tell him to stop
doing anything he enjoys. My diagnosis is probably wrong, but you're not a
doctor so how could you possibly catch me out? If he's not better in two
weeks, come back and see me, and we'll go round the whole mill again, with
slightly different pills."

Sounds a lot like most people's approach to debugging, doesn't it?

What may be accurate (and I really can't tell) is that the complexity of
a human body from the doctor's (or even specialist's) point of view may
be "relatively simple" compared to the actual complexity of the system
as a whole (i.e. he doesn't worry about enzyme folding or mitochondria
but whether it "hurts when I do this").
Ah, we are re-approaching reality (admittedly from a slightly unexpected
direction).
At *that* level we may perhaps
compare doctors and programmers, but we will probably find out more
about how effective humans can organize complexity than about the actual
measure of complexity involved -- intuitively speaking, since an
objective measure of complexity is a tricky thing.
A doctor generally refers anything even mildly tricky to a specialist,
whereas a maintenance programmer chasing a bug generally has to deal with
whatever he finds, no matter how scary. About the best he can hope for is
that the guy in the next office (or cubicle, or whatever) will be able to
help out if he gets stuck.
It
doesn't particularly help the situation that programming is a creative
discipline, and creative people do so love to create stuff!

Programmers are like jazz musicians, except that for jazz musicians, it
works.


......
DE 01 00 00 02 0D 00 00 14 00 00 00 01 02 00 00
20 00 00 00 01 02 00 00 4C 07 00 00 01 0B 00 00
3C 08 00 00 01 0F 00 00 CC 08 00 00 01 10 00 00
5C 09 00 00 01 11 00 00 EC 09 00 00 01 02 00 00
......and that's code, man!

The source of the complexity is irrelevant, and in any case most of
the complexity I face is not complexity I created myself, but
complexity created by other programmers. So the fact that *a* human
created it is no consolation, since it wasn't *this* human that
created it.

But you do realize how this is a self-perpetuating situation?


Yes.
Programming is complex because people make it complex, and they're not
overly concerned with simplifying it because everyone has to be smart
enough to deal with someone else's complexity anyway. It's almost the
programmer's equivalent of the Peter principle.
Yup.
If programmers then point out that programming is so tough and how
nobody is really to blame individually, should we sympathize with them
or mock them?
We should find ways of reducing the complexity that don't just involve
slapping on another layer.
It can be annoying to discuss things with people who agree with you...


I agree!

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #18

P: n/a
Richard Heathfield wrote:
Skarmander said:
You think you know complexity when you hear about
millions of lines of code, but a computer program is a child's toy
compared to a genetic blueprint,

Oops, paradigm clash. How many GPs do genetics research as part of their
daily work? I thought we were talking about doctors, not propeller-heads.

We were, but then you started comparing program complexity to the
complexity of the human body. You clashed your own pair of dimes.

I think we can wrap up this thread by concluding that I had a nice time
arguing for the sake of arguing, and you were kind enough to indulge me.

S.
Nov 15 '05 #19

P: n/a
Skarmander said:
Richard Heathfield wrote:
Skarmander said:
You think you know complexity when you hear about
millions of lines of code, but a computer program is a child's toy
compared to a genetic blueprint,

Oops, paradigm clash. How many GPs do genetics research as part of their
daily work? I thought we were talking about doctors, not propeller-heads.

We were, but then you started comparing program complexity to the
complexity of the human body.


Only the bits the doctor pokes and prods.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 15 '05 #20

P: n/a
pete wrote
(in article <43***********@mindspring.com>):
Jack Klein wrote:

On 13 Nov 2005 00:29:53 -0800, "SK" <ba******@aol.com> wrote in
comp.lang.c:

I am trying to teach myself how to program in C. I am a physician
hoping to be able to help restructure my office.

Please provide your instructor's email address and we'll send you
completed assignment directly.


I wonder if the assignment was stated as
"You are a physician, and hoping ..."?


The naive crop is doing well this year. :-)
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 19 '05 #21

P: n/a
Richard Heathfield wrote
(in article
<dl**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>):
a
statement I doubt you are qualified to make, unless indeed you are
experienced in both -- but then I would have expected you to mention that.


Well, I'm not a doctor. But in fact programming is vastly more complicated
than general medical practice. The doctor has just one (admittedly very
complex) system to worry about, and he can devote years to studying just
that one system. The programmer has to deal with a great many complex
systems at many different levels of abstraction - far more than the doctor
will ever face. (It is normally the case, however, that the stakes are
higher for doctors, since a mistake can cost a patient's life; whilst some
programmers do deal with safety-critical systems, this tends to be the
exception rather than the rule.)


Well, thinking about the number of planes, trains, automobiles,
ships, missiles, air-traffic control systems, traffic light
controllers, microwave ovens, power plants, xray machines, etc.,
etc., etc. in the world, I begin to wonder about what the
"exception" and what the "rule" really should be, especially in
the bounds of currently implemented C.

In fact, the more I think of it, the more I would like a signed
document from the companies producing such products to the
effect that the developers had all read and understood the CLC
FAQ prior to start of the programs involved. :-)

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 19 '05 #22

P: n/a
In article <00*****************************@news.verizon.net> , Randy
Howard <ra*********@FOOverizonBAR.net> writes
Richard Heathfield wrote
(in article
<dl**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>):
a
statement I doubt you are qualified to make, unless indeed you are
experienced in both -- but then I would have expected you to mention that.


Well, I'm not a doctor. But in fact programming is vastly more complicated
than general medical practice. The doctor has just one (admittedly very
complex) system to worry about, and he can devote years to studying just
that one system. The programmer has to deal with a great many complex
systems at many different levels of abstraction - far more than the doctor
will ever face. (It is normally the case, however, that the stakes are
higher for doctors, since a mistake can cost a patient's life; whilst some
programmers do deal with safety-critical systems, this tends to be the
exception rather than the rule.)


Well, thinking about the number of planes, trains, automobiles,
ships, missiles, air-traffic control systems, traffic light
controllers, microwave ovens, power plants, xray machines, etc.,
etc., etc. in the world, I begin to wonder about what the
"exception" and what the "rule" really should be, especially in
the bounds of currently implemented C.

In fact, the more I think of it, the more I would like a signed
document from the companies producing such products to the
effect that the developers had all read and understood the CLC
FAQ prior to start of the programs involved. :-)


This is where the licensing of Engineers starts to come in.... It is
happening in a dozen or so countries now including parts of the US

What is being required is conformance to a defined process ie 61508,
60601-1-4 etc using tools that have been tested and or validated (eg
like the certified Ada compilers,). The standards like 61508 usually
call for things like static testing and, in the case of C a subset (like
MISRA-C) etc as well as the use of suitably qualified programmers. H

However the lengths you need to go to depends on the SIL rating of the
product. So in some cases requirements are very loose through to Safety
Critical systems (ie something vital in a passenger jet) whey you have
to implement al the rules.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 19 '05 #23

P: n/a
Chris Hills wrote
(in article <sW**************@phaedsys.demon.co.uk>):
Well, thinking about the number of planes, trains, automobiles,
ships, missiles, air-traffic control systems, traffic light
controllers, microwave ovens, power plants, xray machines, etc.,
etc., etc. in the world, I begin to wonder about what the
"exception" and what the "rule" really should be, especially in
the bounds of currently implemented C.

In fact, the more I think of it, the more I would like a signed
document from the companies producing such products to the
effect that the developers had all read and understood the CLC
FAQ prior to start of the programs involved. :-)
This is where the licensing of Engineers starts to come in.... It is
happening in a dozen or so countries now including parts of the US


It's not even remotely close to "happening" in the US. I wish
it would, but don't hold your breath.
What is being required is conformance to a defined process ie 61508,
60601-1-4 etc using tools that have been tested and or validated (eg
like the certified Ada compilers,). The standards like 61508 usually
call for things like static testing and, in the case of C a subset (like
MISRA-C) etc as well as the use of suitably qualified programmers.


I knew when I wrote the above that you would probably come back
with something about MISRA. MISRA doesn't prevent bad
programmers from writing bad code though. Sadly.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 19 '05 #24

P: n/a
In article <00*****************************@news.verizon.net> , Randy
Howard <ra*********@FOOverizonBAR.net> writes
Chris Hills wrote
(in article <sW**************@phaedsys.demon.co.uk>):
Well, thinking about the number of planes, trains, automobiles,
ships, missiles, air-traffic control systems, traffic light
controllers, microwave ovens, power plants, xray machines, etc.,
etc., etc. in the world, I begin to wonder about what the
"exception" and what the "rule" really should be, especially in
the bounds of currently implemented C.

In fact, the more I think of it, the more I would like a signed
document from the companies producing such products to the
effect that the developers had all read and understood the CLC
FAQ prior to start of the programs involved. :-)


This is where the licensing of Engineers starts to come in.... It is
happening in a dozen or so countries now including parts of the US


It's not even remotely close to "happening" in the US. I wish
it would, but don't hold your breath.


http://www.acm.org/serving/se_policy/report.html
//////////////
Finding 1: The licensing of Software Engineers will happen in Texas (and
elsewhere) with or without ACM involvement.

The Texas Board of Professional Engineers is charged by the state
legislature with implementing and enforcing the licensing of
professional engineers (PEs). Since the Texas Board interprets the
legislative mandate as including software engineers, it seems inevitable
that licensing will be required in Texas. In fact at least one Software
Engineer has already been licensed.
/////////////

There are a dozen countries looking at various forms of licensing.

In the UK it will be based on the long standing Chartered Engineer
"qualification" Which, like all the other similar methods, requires a
relevant degree + training + experience. In the case of those without a
degree and formal training there is usually a much higher experience
requirement and some sort of report/thesis signed off by other suitably
qualified people.

It's not perfect. Some "idiots" will get though and some good people
will be lost but overall it will be good. With more and more [embedded]
software controlling every aspect of life (and much of it directly
affecting the public) the insurance companies will start to require some
sort of licencing and legislation just as the do for

doctors
lawyers
civil engineers
architects
aero-engineers
teachers
etc
What is being required is conformance to a defined process ie 61508,
60601-1-4 etc using tools that have been tested and or validated (eg
like the certified Ada compilers,). The standards like 61508 usually
call for things like static testing and, in the case of C a subset (like
MISRA-C) etc as well as the use of suitably qualified programmers.


I knew when I wrote the above that you would probably come back
with something about MISRA. MISRA doesn't prevent bad
programmers from writing bad code though. Sadly.


It helps but... only as part of a calorie controlled process :-) MISRA-C
is only one of several coding guides that could be used. However in
itself it is of little use if the development is a shambles.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 19 '05 #25

P: n/a
Chris Hills wrote
(in article <7g**************@phaedsys.demon.co.uk>):
It's not even remotely close to "happening" in the US. I wish
it would, but don't hold your breath.
http://www.acm.org/serving/se_policy/report.html

<snip> In fact at least one Software Engineer has already been licensed.
Oh goodie. Guess what percentage of all of the programmers in
the US is represented by 'one'. Thanks for reinforcing my
point.
There are a dozen countries looking at various forms of licensing.
And zero actually doing anything useful about it. Meanwhile,
just about all of them will arrest you for trying to pretend you
are a doctor without the appropriate proof of competency.
the insurance companies will start to require some
sort of licencing and legislation just as the do for

doctors
lawyers
civil engineers
architects
aero-engineers
teachers
etc
I am sort of wondering how an insurance company can require a
programmer to be licensed. I'm not sure the insurance company
had anything to do with any of the above groups until long after
they already had licensing in place.
MISRA doesn't prevent bad programmers from writing bad code though.

It helps but... only as part of a calorie controlled process :-)
I haven't seen any evidence that it has any beneficial impact at
all on a properly trained programmer. If anything, it seems
more like a crutch aimed at propping up people that aren't
grounded properly in the first place.
MISRA-C is only one of several coding guides that could be used.
One of an almost infinite number actually.
However in itself it is of little use ...


Couldn't agree more. :-)
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 19 '05 #26

P: n/a
In article <00*****************************@news.verizon.net> , Randy
Howard <ra*********@FOOverizonBAR.net> writes
Chris Hills wrote
(in article <7g**************@phaedsys.demon.co.uk>):
It's not even remotely close to "happening" in the US. I wish
it would, but don't hold your breath.
http://www.acm.org/serving/se_policy/report.html

<snip>
In fact at least one Software Engineer has already been licensed.


Oh goodie. Guess what percentage of all of the programmers in
the US is represented by 'one'. Thanks for reinforcing my
point.


The difference between 0 and 1 is greater than between 1 and 1000...
There are a dozen countries looking at various forms of licensing.
And zero actually doing anything useful about it. Meanwhile,
just about all of them will arrest you for trying to pretend you
are a doctor without the appropriate proof of competency.


Or almost any other profession....
the insurance companies will start to require some
sort of licencing and legislation just as the do for

doctors
lawyers
civil engineers
architects
aero-engineers
teachers
etc
I am sort of wondering how an insurance company can require a
programmer to be licensed.


That is easy... Various standards for safety critical work require
personnel to be suitably qualified already.
I'm not sure the insurance company
had anything to do with any of the above groups until long after
they already had licensing in place.

Agreed.
MISRA doesn't prevent bad programmers from writing bad code though.
It helps but... only as part of a calorie controlled process :-)


I haven't seen any evidence that it has any beneficial impact at
all on a properly trained programmer. If anything, it seems
more like a crutch aimed at propping up people that aren't
grounded properly in the first place.


Probably true. It moves the minimum up a bit.
MISRA-C is only one of several coding guides that could be used.


One of an almost infinite number actually.


Yes. Some are better than others. Due to the high profile and use of
MISRA-C it is getting a lot more feedback etc so MISRA-C3 will be better
still. Most of the other coding guides do not have such widespread use
or an active maintenance team.

However in itself it is of little use ...


Couldn't agree more. :-)


The process is important. A coding guide is simply one (small) part of
it.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 20 '05 #27

P: n/a
Chris Hills wrote
(in article <zI**************@phaedsys.demon.co.uk>):
In fact at least one Software Engineer has already been licensed.
Oh goodie. Guess what percentage of all of the programmers in
the US is represented by 'one'. Thanks for reinforcing my
point.


The difference between 0 and 1 is greater than between 1 and 1000...


<insert comment about the uselessness of statistics here>
There are a dozen countries looking at various forms of licensing.


And zero actually doing anything useful about it. Meanwhile,
just about all of them will arrest you for trying to pretend you
are a doctor without the appropriate proof of competency.


Or almost any other profession....


Exactly. Almost 'by definition', programming is not a
profession as a result. No wonder they are paying people in
grains of rice to do it.
I am sort of wondering how an insurance company can require a
programmer to be licensed.


That is easy... Various standards for safety critical work require
personnel to be suitably qualified already.


Those requirements might be generated by a company in response
to an insurance company requiring them to in order to get a
lower premium, sure. That, or they lobby government to pass
laws to that effect.
MISRA doesn't prevent bad programmers from writing bad code though.

It helps but... only as part of a calorie controlled process :-)


I haven't seen any evidence that it has any beneficial impact at
all on a properly trained programmer. If anything, it seems
more like a crutch aimed at propping up people that aren't
grounded properly in the first place.


Probably true. It moves the minimum up a bit.


I disagree. It allows people to play in the space that might
otherwise be weeded out more quickly. Everytime you 'move the
minimum up', you need to determine whether or not that is
desirable.
The process is important. A coding guide is simply one (small) part of
it.


A coding guide will not save you from bad programming. You can
write broken code that adheres to almost any programming guide
you devise.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 21 '05 #28

This discussion thread is closed

Replies have been disabled for this discussion.