Please Help me solve these two questions

C

Common Man

"... and I am Marie of Roumania."



--

Eric Sosman

(e-mail address removed)


I understood evrything except these lines of 3rd function
for (int d114; ; ++d114) {
if ((d114 = rand() % 0200) > 0) {

for (int d112 = d114; ;) {

if ((d112 = d112 * 0x12d1 % 0177) == d114) {
Anyway I'm trying to understand in my own effort. also I have solved the first question, I will post it for everyone very soon after a little bit of review.I'm a beginner So please pardon my ignorance. But I wish very soon I'll be a master of it.
 
B

BartC

I understood evrything except these lines of 3rd function
for (int d114; ; ++d114) {
Anyway I'm trying to understand in my own effort. also I have solved the
first question, I will post it for everyone very soon after a little bit
of review.I'm a beginner So please pardon my ignorance. But I wish very
soon I'll be a master of it.

Don't bother. The code is meant to be a joke.
 
O

osmium

:

I understood evrything except these lines of 3rd function
<snip>

That makes me believe you are not a truth teller. You ARE in a class and
totally lost. the code posted made no sense, and a self-student would at
least realize that.
 
E

Eric Sosman

[...]
That makes me believe you are not a truth teller. You ARE in a class and
totally lost. the code posted made no sense, and a self-student would at
least realize that.

"No sense?" The code compiles, executes, and satisfies the
requirements of the question (if you squint enough when reading
and make reasonable assumptions about age ranges). By intention
it is not a strictly conforming program, but it is almost entirely
portable (diagnosing the two small portability problems is left
as an exercise). "No sense?" C'mon!
 
O

osmium

Eric Sosman said:
[...]
That makes me believe you are not a truth teller. You ARE in a class and
totally lost. the code posted made no sense, and a self-student would
at
least realize that.

"No sense?" The code compiles, executes, and satisfies the
requirements of the question (if you squint enough when reading
and make reasonable assumptions about age ranges). By intention
it is not a strictly conforming program, but it is almost entirely
portable (diagnosing the two small portability problems is left
as an exercise). "No sense?" C'mon!

<one handed typing>

I do not consider it sensible to "expose" the instructor as a stupid doofus
who used imprecision in his phrasing of the question. it IS a beginner's
course, after all.

YMMV
 
C

Common Man

That makes me believe you are not a truth teller. You ARE in a class and
totally lost. the code posted made no sense, and a self-student would at
least realize that.



"No sense?" The code compiles, executes, and satisfies the

requirements of the question (if you squint enough when reading

and make reasonable assumptions about age ranges). By intention

it is not a strictly conforming program, but it is almost entirely

portable (diagnosing the two small portability problems is left

as an exercise). "No sense?" C'mon!



--

Eric Sosman

(e-mail address removed)

That's what I told. I could not get any sense from that piece of code.
 
J

James Kuyper

That makes me believe you are not a truth teller. You ARE in a class and
totally lost. the code posted made no sense, and a self-student would at
least realize that.

"No sense?" The code compiles, executes, and satisfies the
requirements of the question (if you squint enough when reading
and make reasonable assumptions about age ranges). By intention
it is not a strictly conforming program, but it is almost entirely
portable (diagnosing the two small portability problems is left
as an exercise). "No sense?" C'mon!
....
That's what I told. I could not get any sense from that piece of code.

That is a more believable statement than your earlier comment that
osmium objected to: "I understood evrything except these lines of 3rd
function". As Bart said, Eric's response was meant as a joke; you will
often get responses like that if you ask a question that looks like
homework, and give no indication that you've made any attempt to work on
it on your own.

If you had even a minimal understanding of C, there should have been
some questions you would have been asking as soon as you finished
understanding the first two functions, even if you had not yet realized
it was a joke:
1. Where are the names and the ages stored after they are read in from
the input file?
2. When the program asks for a name, and the user types it in, where is
the name stored?

Even if you can't figure out the answers to those questions, failing to
even ask them implies a really poor understanding of C. This seems like
a fairly elementary exercise, but it requires an understanding of C
greater than your current level. If you really do want to learn C, I
recommend backing up and working on some simpler exercises before
tackling a problem as complicated as this one.

If you had understood the third function as well, you should have been
asking an additional question:
3. What is the connection between the names in the data file, the name
that the user types in, and the age that is prints out?

I recommend examining the code carefully to figure out what's wrong with
it - you'll learn some important things about computer programming.
Important point: there's nothing significant wrong with it, as a C
program. The key problem with it is the connection between what that
program does and the instructions you were given. Technically, it obeys
those instructions, but only by completely ignoring the clearly intended
meaning of word "corresponding".
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top