need assingment to teach

  • Thread starter vikram Bhuskute
  • Start date
K

Keith Thompson

Mark McIntyre said:
On Mon, 10 Sep 2007 02:27:48 +0000, in comp.lang.c , Richard


Unfair - I suspect you learned with pre-ANSI C (heck, I did, and I'm
younger than you).

That seems unlikely, since the 'void' keyword didn't exist prior to
the ANSI standard (or at least some early draft of it).

I've always wondered how the 'void main' error took hold in the first
place, since the same document that introduced 'void' clearly stated
that main returns int. Or did 'void' originate earlier than that?
 
B

Ben Bacarisse

Keith Thompson said:
That seems unlikely, since the 'void' keyword didn't exist prior to
the ANSI standard (or at least some early draft of it).

I've always wondered how the 'void main' error took hold in the first
place, since the same document that introduced 'void' clearly stated
that main returns int. Or did 'void' originate earlier than that?

I suspect that it may be entirely due to bad teaching. (What do you
know, we've come full circle and are topical again!)

Simple C programs used to be easy to explain in the good/bad old
days. My old K&R's first program is:

main()
{
printf("Hello world\n");
}

No #include to explain. No need to bother quite yet about "int
main". No "return 0;".

If someone got the idea that "void main" *might* be allowed, it would
have strong teacher appeal since it allows a simplification of early
examples. Of course, once taught, it sticks. There may be much poor
teaching but there is also poor learning -- very few students will
challenge what they are told.

Other than in Algol 68, I first met void around 1986, but I was using
both C and C++ at that time so I don't know which came first. Because
of having used Algol 68, it seemed quite natural to me. Some C code
of mine from that period uses void, but I can't be sure that it does
not come from a later "tidy up". Keepers of old compilers must know
what was added when...
 
P

Peter Nilsson

Richard Heathfield said:
... All the mathematics teachers I ever had believed 1 to
be prime. ...

People who quible over whether 1 is prime or not are
usually people for whom the difference is entirely
superficial! ;-)

The common definition of prime in schools is actually the
definition attributed to a related, but distinct, property of
'irreducability'.

In the domain of Gaussian integers, 5 is irreducable in
that it has no factors other than itself and unity
(ignoring sign), yet it is not prime!

Depending on which mathematician you talk to, a prime
is often defined as an element that if it divides a
product of 2 elements, then it also divides at least
one of the elements in the product. Thus, 6 is not a
prime. Not because it has the factors of 2 and 3, but
because it divides 12 without dividing 3 or 4.

Fact is, units fit nicely into either definition. What
matters is when you start to apply the definition to
build theorems. Sometimes units are incidental, mostly
they're a hinderance. Hence it is more common to
explicitly exclude them.

[Mathematicians don't care which definition you use.
What matters is whether you use the definition
rigorously.]

My point is that dumbing things down is a common and
valuable teaching tool. The concept of primes is a
good example. It is the irreducable property of primes
that sparks people's interest. Their real meaning
is unwieldy and... boring!
 
R

Richard Heathfield

Peter Nilsson said:

[Mathematicians don't care which definition you use.
What matters is whether you use the definition
rigorously.]

Certainly true. But...
My point is that dumbing things down is a common and
valuable teaching tool. The concept of primes is a
good example. It is the irreducable property of primes
that sparks people's interest. Their real meaning
is unwieldy and... boring!

If 1 is prime, all positive integers are reducible to it, which makes
the whole subject of primes pretty dull. By removing 1 from the primes,
however, the real meaning of primes becomes much more *interesting*.
For one thing, you open the door to the FTA, which is interesting in
its own right. (They never taught me the FTA at school, probably
because they'd never heard of it themselves.)
 
M

Mark McIntyre

I've always wondered how the 'void main' error took hold in the first
place,

Probably with ignoramuses who assumed that
main(){
returned what it appears to - ie nothing....
since the same document that introduced 'void' clearly stated
that main returns int. Or did 'void' originate earlier than that?

ISTR that void was around pre-ansi. ICBW.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

If 1 is prime, all positive integers are reducible to it, which makes
the whole subject of primes pretty dull.

Perhaps. But you don't start teaching chemistry by explaining about
energy levels in the electron shells and weak interactions. And you
don't start teaching C by diving straight into advanced networking.
One starts simple, ignoring the simplifications in the temporary
model, and then moves on to more 'accurate' models as your students
become more adept. There is of course no 'right' model, since all our
models are approximations.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard Bos

Mark McIntyre said:
Perhaps. But you don't start teaching chemistry by explaining about
energy levels in the electron shells and weak interactions. And you
don't start teaching C by diving straight into advanced networking.

There is, however, a difference between simplifying and direct lies.
Teachers who neglect to tell you about abort() when they discuss
main()'s return type do the first; teachers who tell you that void
main() is all right (of whom there are too bloody many) do the second.

Richard
 
M

Mark McIntyre

On Wed, 12 Sep 2007 08:05:03 GMT, in comp.lang.c ,
There is, however, a difference between simplifying and direct lies.
Teachers who neglect to tell you about abort() when they discuss
main()'s return type do the first; teachers who tell you that void
main() is all right (of whom there are too bloody many) do the second.

I understand your point and agree its bad teaching, but you're
incorrect to say the teacher is lying. Using void main() may be
nonstandard, but it is documented on some implementations
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard Bos

Mark McIntyre said:
On Wed, 12 Sep 2007 08:05:03 GMT, in comp.lang.c ,


I understand your point and agree its bad teaching, but you're
incorrect to say the teacher is lying. Using void main() may be
nonstandard, but it is documented on some implementations

So is int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow), but that doesn't make either of the all
right in a C programming course. In a M$ programming course, maybe.

Richard
 
M

Malcolm McLean

Richard Bos said:
So is int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow), but that doesn't make either of the all
right in a C programming course. In a M$ programming course, maybe.
That's for teacher to decide. Whether to teach ANSI C first, and then move
on to platforms, or teach one platform and then specify that only a subset
is ANSI.
The second would seem more natural, but if only one type of computer is
avialable, you don't necessarily want to have to tell enthusiastic students
all the time "Yes, I like those space invaders, but conio and printxy() are
non-standard. There's also no way of scanning the keyboard in ANSI C. Try
lunar lander instead".
 
C

Charlton Wilbur

MMcI> On Wed, 12 Sep 2007 08:05:03 GMT, in comp.lang.c ,

MMcI> I understand your point and agree its bad teaching, but
MMcI> you're incorrect to say the teacher is lying.

....in part, because "lying" involves an intentional misrepresentation,
and by far the majority of the people who promote void main() do so
out of ignorance or incompetence, not malice.

Charlton
 
D

Duncan Muirhead

I have plans to train some students for C in coming weeks.
I am badly looking for C programming assignments fot them.
Need 1) lots of them per topiic 2) Should be doable for beginners

thanks in advance

Vikram
A random thought: the assignments could build up a simple suite
of programs to create/manipulate files that contain sounds. For example
..wav files have a pretty simple format, and a fairly simple exercise
would be to produce a file that had a couple of seconds of a sinusoid
of some given frequency. Then you could go on to programs that concatenate
files, that merged them etc etc.
 
O

Old Wolf

...in part, because "lying" involves an intentional misrepresentation,
and by far the majority of the people who promote void main() do so
out of ignorance or incompetence, not malice.

Or intent. If the course is teaching how to use
Borland C, for example, then void main() is quite correct.
 
K

Keith Thompson

Old Wolf said:
Or intent. If the course is teaching how to use
Borland C, for example, then void main() is quite correct.

I presume that Borland C's documentation specifically states that
'void main()' is supported.

If it's a conforming hosted implementation, it also allows
'int main(void)' and 'int main(int argc, char **argv)'. Using one of
the more portable forms makes it more likely that the user's program
will work under other C implementations, at virtually no cost.
Teaching students to use 'void main()', without mentioning the price
to be paid for doing so, may be "correct", but it doesn't strike me as
a very good idea.
 
R

Richard Heathfield

Old Wolf said:
Or intent. If the course is teaching how to use
Borland C, for example, then void main() is quite correct.

No, it's quite incorrect. Borland C /tolerates/ void main, but by no
means requires it. Indeed, it will diagnose void main when invoked in
conforming mode.
 
R

Richard Bos

Charlton Wilbur said:
MMcI> On Wed, 12 Sep 2007 08:05:03 GMT, in comp.lang.c ,


MMcI> I understand your point and agree its bad teaching, but
MMcI> you're incorrect to say the teacher is lying.

...in part, because "lying" involves an intentional misrepresentation,
and by far the majority of the people who promote void main() do so
out of ignorance or incompetence, not malice.

Bah. Hanlon's Razor is over-general: ignorance which exist where there
is no excuse for it (for example, in a teacher, regarding the basics of
his own subject) _is_ a form of malice.

Ignorance, when it is voluntary, is criminal; and he may be properly
charged with evil who refused to learn how he might prevent it.
-- Johnson, Rasselas, ch. XXIX

Richard
 
C

Chris Torek

[regarding "void main" and other such horrors :) ]

That seems unlikely, since the 'void' keyword didn't exist prior to
the ANSI standard (or at least some early draft of it).
I've always wondered how the 'void main' error took hold in the first
place, since the same document that introduced 'void' clearly stated
that main returns int. Or did 'void' originate earlier than that?

The original K&R "White Book", published in 1978, did not include
"void" or "enum". However, by 1980 at the latest, and probably
earlier, Unix-system C compilers had both "void" and "enum" keywords,
and also had moved structure members into their own separate
name-spaces, so that:

struct A { int i, j; };
struct B { double d; int i; };

was now valid (even though there were now two ".i" fields, with
different offsets, in the two different "struct" types).

These changes were summarized on a one-or-two page file included
somewhere in the Unix file tree (probably under /usr/doc).

(How people ever got the idea of using "void main", though, I am
not sure.)
 
D

David Thompson

On Mon, 10 Sep 2007 02:27:48 +0000, Richard Heathfield
One of my English teachers thought "collier" had only one "l", and
called me a liar for claiming that the dictionary thought otherwise
(thus introducing me to the wonderful concept of deceit for the very

Well said:
first time). All the mathematics teachers I ever had believed 1 to be
prime. I had a chemistry teacher who couldn't spell "beryllium". My
first ever C tutor thought that loops terminated as soon as their
condition was false (which, if it were the case, would massively
increase the size of the object code for all loops, since *every*
translated instruction within the loop would have to be followed by a
test and conditional jump!), and all my C tutors voided main with
carefree abandon. I remember a systems analysis lecturer who honestly
believed that multiplication was non-commutative (he thought that the
saving given by multiple discount percentages depended on the order in
which the discounts were applied). I have experienced enough examples

That one might accidentally have been right -- if each discount is
separately rounded to penny or similar, as was usual in the days of
hand, mechanical calculator or register, or preprinted table (usually
most convenient, especially for themselves-ill-taught clerks).

<vaguely_sortof_ontopic> cf Goldberg on floating-point </>

Nowadays, I wouldn't be too surprised to find out that computerized
registers try all permutations to find the one most favorable to the
merchant. However, I don't encounter too many situations where
multiple percentage discounts apply to one item; it seems most
businesses at least in my part of the world have caught on to the
magic incantation 'may not be combined with any other offer'.
(Plus many are stated by amount rather than percentage anyway.)
of poor teaching to last me a lifetime. On the other hand, I have
encountered very few examples of *excellent* teaching. Some, yes. But
precious few.
- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,795
Messages
2,569,644
Members
45,359
Latest member
1854578

Latest Threads

Top