Velocity Reviews > beginner c questions

# beginner c questions

Randy Howard
Guest
Posts: n/a

 11-04-2005
matt wrote
(in article
<(E-Mail Removed) .com>):

> I new to programming and have started with c. I am stuck on 2 questions
> and cannot move forward, any help would be greatly appreciated.
>
> Question 1: Express each number as a floating-point constant using both
> regular decimal notation and exponential notation.
> a) 1,234
> b) 1,234.5
> c) 0.1234
> d) 1.234 x 10 to the second power

My daughter is currently doing this sort of work in elementary
school. I can't imagine a college instructor being able to
stump a student on something this easy.

> Question 2: Express each number as an integer constant, an octal
> constant, and a hexadecimal constant.
> a) 1,234
> b) 2
> c) 8
> d) 16
> e) 1,024

This is slightly more difficult, but certainly something that
almost any "scientific" calculator can do on your behalf. Jeez,
before you fill your transcript with a semester's worth of F's.

--
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

pete
Guest
Posts: n/a

 11-04-2005
Randy Howard wrote:
>
> matt wrote
> (in article
> <(E-Mail Removed) .com>):
>
> > I new to programming and have started with c.
> > I am stuck on 2 questions
> > and cannot move forward, any help would be greatly appreciated.
> >
> > Question 1:
> > Express each number as a floating-point constant using both
> > regular decimal notation and exponential notation.
> > a) 1,234
> > b) 1,234.5
> > c) 0.1234
> > d) 1.234 x 10 to the second power

>
> My daughter is currently doing this sort of work in elementary
> school. I can't imagine a college instructor being able to
> stump a student on something this easy.
>
> > Question 2: Express each number as an integer constant, an octal
> > constant, and a hexadecimal constant.
> > a) 1,234
> > b) 2
> > c) 8
> > d) 16
> > e) 1,024

>
> This is slightly more difficult, but certainly something that
> almost any "scientific" calculator can do on your behalf. Jeez,
> this is trivial. If you can't answer these, change your major
> before you fill your transcript with a semester's worth of F's.

On 2 November Martin Ambuhl posted a printf solution,
which corresponded to my initial take on the problem,
that it was supposed to be a printf exercise.

To me, it looks like a problem that belongs
after an introduction to format specifiers.

--
pete

Keith Thompson
Guest
Posts: n/a

 11-04-2005
pete <(E-Mail Removed)> writes:
> Randy Howard wrote:
>> matt wrote
>> (in article
>> <(E-Mail Removed) .com>):
>> > I new to programming and have started with c.
>> > I am stuck on 2 questions
>> > and cannot move forward, any help would be greatly appreciated.
>> >
>> > Question 1:
>> > Express each number as a floating-point constant using both
>> > regular decimal notation and exponential notation.
>> > a) 1,234
>> > b) 1,234.5
>> > c) 0.1234
>> > d) 1.234 x 10 to the second power

[snip]
>> > Question 2: Express each number as an integer constant, an octal
>> > constant, and a hexadecimal constant.
>> > a) 1,234
>> > b) 2
>> > c) 8
>> > d) 16
>> > e) 1,024

>>
>> This is slightly more difficult, but certainly something that
>> almost any "scientific" calculator can do on your behalf. Jeez,
>> this is trivial. If you can't answer these, change your major
>> before you fill your transcript with a semester's worth of F's.

>
> On 2 November Martin Ambuhl posted a printf solution,
> which corresponded to my initial take on the problem,
> that it was supposed to be a printf exercise.
>
> To me, it looks like a problem that belongs
> after an introduction to format specifiers.

I don't think so. The question is about numeric literals that might
appear in a C program, not necessarily about the output produced by
printf(). It happens that printf's numeric output usually (always?)
looks like a valid numeric literal, but the questions can be answered
with no knowledge of printf formats. (printf can be used as a tool to
find the answers, but it's hardly necessary.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

matt
Guest
Posts: n/a

 11-05-2005
You must not have read through the entire post so I wont hold it
against you. I am not a college student, this questions are not for a
class. I just needed to brush up on trivial math I have not use since
school. Must of the others who replied actually helped point me in the
right direction. As for you, why do you feel the need to compare me

Randy Howard wrote:
> matt wrote
> (in article
> <(E-Mail Removed) .com>):
>
> > I new to programming and have started with c. I am stuck on 2 questions
> > and cannot move forward, any help would be greatly appreciated.
> >
> > Question 1: Express each number as a floating-point constant using both
> > regular decimal notation and exponential notation.
> > a) 1,234
> > b) 1,234.5
> > c) 0.1234
> > d) 1.234 x 10 to the second power

>
> My daughter is currently doing this sort of work in elementary
> school. I can't imagine a college instructor being able to
> stump a student on something this easy.
>
> > Question 2: Express each number as an integer constant, an octal
> > constant, and a hexadecimal constant.
> > a) 1,234
> > b) 2
> > c) 8
> > d) 16
> > e) 1,024

>
> This is slightly more difficult, but certainly something that
> almost any "scientific" calculator can do on your behalf. Jeez,
> this is trivial. If you can't answer these, change your major
> before you fill your transcript with a semester's worth of F's.
>
>
> --
> Randy Howard (2reply remove FOOBAR)
> "The power of accurate observation is called cynicism by those
> who have not got it." - George Bernard Shaw

Dennis Willson
Guest
Posts: n/a

 11-05-2005

matt wrote:
> You must not have read through the entire post so I wont hold it
> against you. I am not a college student, this questions are not for a
> class. I just needed to brush up on trivial math I have not use since
> school. Must of the others who replied actually helped point me in the
> right direction. As for you, why do you feel the need to compare me
>

Gee, when I read your original post, it looks to me like your asking for help in the coding not the math. Yet his post looks to me
like he thinks you're having trouble with the math. Big difference, when you don't know the programming language something that can
easily be done on a scientific calculator isn't always easy to do in code.

Some people like to jab and stroke their ego rather than actually help, or keep their fingers off the keyboard.

> Randy Howard wrote:
>
>>matt wrote
>>(in article
>><(E-Mail Removed) ps.com>):
>>
>>
>>>I new to programming and have started with c. I am stuck on 2 questions
>>>and cannot move forward, any help would be greatly appreciated.
>>>
>>>Question 1: Express each number as a floating-point constant using both
>>>regular decimal notation and exponential notation.
>>>a) 1,234
>>>b) 1,234.5
>>>c) 0.1234
>>>d) 1.234 x 10 to the second power

>>
>>My daughter is currently doing this sort of work in elementary
>>school. I can't imagine a college instructor being able to
>>stump a student on something this easy.
>>
>>
>>>Question 2: Express each number as an integer constant, an octal
>>>a) 1,234
>>>b) 2
>>>c) 8
>>>d) 16
>>>e) 1,024

>>
>>This is slightly more difficult, but certainly something that
>>almost any "scientific" calculator can do on your behalf. Jeez,
>>before you fill your transcript with a semester's worth of F's.
>>
>>
>>--
>>"The power of accurate observation is called cynicism by those
>> who have not got it." - George Bernard Shaw

>
>

Sandeep
Guest
Posts: n/a

 11-05-2005
Dennis Willson wrote:
>Big difference, when you don't know the programming language something that can
> easily be done on a scientific calculator isn't always easy to do in code.

Coding is one thing, but if someone does not even know how to convert
it using a scientific calculator , I am sure he/she will not be able to
code it.

> Some people like to jab and stroke their ego rather than actually help, or keep their fingers >off the keyboard.

You did no better to help

Dominic Shields
Guest
Posts: n/a

 11-05-2005
On 2 Nov 2005 18:33:14 -0800, "matt" <(E-Mail Removed)> wrote:

>I actually have Kernighan and Ritchie, "The C Programming Language"
>Second Edition. I started with it but I felt it was asking me to write
>c without teaching it first.

When I started with C about 12 years ago I had a copy of that book and
found that for me it was
"Teach yourself C if you are already an expert in C"

I bought "Teach Yourself C" by Herbert Schildt, then "C, The Complete
Reference" by the same author, worked for me.

Naturally, everyone's learning styles differ, I had been a Cobol
programmer for some time, not sure if that helped particularly }

Mabden
Guest
Posts: n/a

 11-05-2005
"Dominic Shields" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 2 Nov 2005 18:33:14 -0800, "matt" <(E-Mail Removed)> wrote:
>
> >I actually have Kernighan and Ritchie, "The C Programming Language"
> >Second Edition. I started with it but I felt it was asking me to

write
> >c without teaching it first.

This is a book that can be re-read many times. You must study the code
examples and understand them before reading the following explanation.
Also, the code itself provides example of a certain "style" of writing
code. It is a subtle and complex book, but it is the finest example of a
textbook I have ever learned from. It does not try to over-explain every
line like the Wrox books, it just gives subtle hints on how to do C.
BTW, look at the size of the book versus the other "tutorials". It is
small, subtle, concise; the exact correct book to describe C.

I remember picking up the first version of K&R, back when I knew BASIC
and FORTRAN from school only - no practical experience. I found it
really hard to get through and when I got to chapter 6 (pointers) I gave
up. I then learned Pascal and Assembler. Assembler taught me how memory
and registers work, and Pascal had one kind of pointer, a "by reference"
thing. Even then I found pointers in C to be something hard to learn.
Hell, we're still talking about page 102 and null pointers today.

So don't feel too bad. Also, realize that you can read past the parts
code, write code.

> When I started with C about 12 years ago I had a copy of that book and
> found that for me it was
> "Teach yourself C if you are already an expert in C"
>
> I bought "Teach Yourself C" by Herbert Schildt, then "C, The Complete
> Reference" by the same author, worked for me.

I don't think you should be saying that name 'round here... ;-(

> Naturally, everyone's learning styles differ, I had been a Cobol
> programmer for some time, not sure if that helped particularly }

Well, BASIC and FORTRAN certainly didn't help much...

--
Mabden

Keith Thompson
Guest
Posts: n/a

 11-05-2005
Dominic Shields <(E-Mail Removed)> writes:
> On 2 Nov 2005 18:33:14 -0800, "matt" <(E-Mail Removed)> wrote:
>
>>I actually have Kernighan and Ritchie, "The C Programming Language"
>>Second Edition. I started with it but I felt it was asking me to write
>>c without teaching it first.

>
> When I started with C about 12 years ago I had a copy of that book and
> found that for me it was
> "Teach yourself C if you are already an expert in C"
>
> I bought "Teach Yourself C" by Herbert Schildt, then "C, The Complete
> Reference" by the same author, worked for me.

Herbert Schildt is a skilled writer of very poor books, full of
dangerous misinformation. If your knowledge of C depends on his
books, it's likely you've picked up some incorrect ideas, particularly
in understanding the difference between portable C and system-specific
features.

Some years ago, he wrote a book consisting of the 1990 ISO C standard
with annotations. See <http://www.lysator.liu.se/c/schildt.html> for
a review. Some of his other books may be marginally better; see
<http://www.accu.org/bookreviews/public/reviews/c/c002173.htm> for a
review of "C, The Complete Reference".

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

Dominic Shields
Guest
Posts: n/a

 11-06-2005
On Sat, 05 Nov 2005 19:49:09 GMT, Keith Thompson <(E-Mail Removed)>
wrote:

>Herbert Schildt is a skilled writer of very poor books, full of
>dangerous misinformation. If your knowledge of C depends on his
>books, it's likely you've picked up some incorrect ideas, particularly
>in understanding the difference between portable C and system-specific
>features.

Well in a way portable C wasn't really on the cards anyway as a lot of
the C I first wrote was what Ingres called ESQL/C but I think I
appreciated right away that the books seemed to refer to C in a DOS
environment rather than things that would work in Unix.