I understand this code.
int a[5];
int b;
for (b=0;b<5;b=b+1)
int a[b];
This should take every element of the array a and set it to 1,2,3,4,5.
Great. Now for the big question. How would you work this?
int a [5][3];
And make the first element of 5 all zeros and the second element of 3 equal
to 1,2,3 ? I don't know how to work with a 2 dimensional array.
Bill
Jul 22 '08
182 4500
"Bill Cunningham" <no****@nspam.comwrites:
[...]
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i\n", i);
}
}
I indented this program using indent. It looks more readable to others
than my usual indentaion.
<OT>Try "indent -kr".</OT>
All this does is print vertically the number 0-7.
I have no idea how to even start working with the line numbers to obtain
exponenials.
The exercise Mark gave you, as I recall, said to print the square of
the number. That's just the number multiplied by itself. For
example, the square of i is i*i.
I don't remember exactly what the exercise was; this thread has gotten
so long I can't easily find it ("easily" meaning within the time and
effort I'm willing to expend right now).
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Well here's my latest attempt. I just get the line numbers.
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
}
}
Bill
Bill Cunningham said:
>
Well here's my latest attempt. I just get the line numbers.
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" ,
i*i*i);
}
}
I have to hand it to you. That's a masterpiece.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
"Bill Cunningham" <no****@nspam.comwrites:
Well here's my latest attempt. I just get the line numbers.
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
Please explain in detail the logic you used to construct this argument
list. If you did not use logic to construct it, go away now.
printf() takes a single format string followed by an optional list of
things to print as specified in that format string.
You've supplied a format string of
"%i\n"
(which says "print an int and a newline") and a list of things, the
first of which is an int. Thus, printf() does exactly as you've asked
and prints that int and a newline and nothing more.
Look at the problem specification again.
On each line you need to print a number of things:
- an int, which is the line number
- a space
- an int, which is the square of the line number
- a space
- an int, which is the cube of the line number
- a newline
This means that you need a format string (the first argument to
printf()) that specifies 3 ints, 2 spaces, and a newline; and the
other arguments need to provide values for the the %-specified
conversions.
So: what format string would tell printf() to print
- an int
- a space
- an int
- a space
- an int
- a newline
?
Don't guess - use the reference material you have available to figure
it out.
mlp
Mark L Pappin <ml*@acm.orgwrites:
"Bill Cunningham" <no****@nspam.comwrites:
>#include <stdio.h>
int main (void) { int i;
for (i = 0; i < 7; i++) {
printf ("%i\n", i); } }
>I indented this program using indent. It looks more readable to others than my usual indentaion.
It'll do. Whatever options you used to run indent, keep using them.
Better don't. Do it by hand. Understand how to indent your own
code. programming, like building a wall, requires skill and pride in
ones work. Recommending "indent" is like recommending an automatic code
generator IMO. If Bill isnt a troll and he just types in any old rubbish
and then expects tools to make it readable only when he posts here then
he has no pride in his work and, frankly, no chance of ever cutting the
mustard.
>
>All this does is print vertically the number 0-7. I have no idea how to even start working with the line numbers to obtain exponenials.
OK, that's fine. Let's recap what you know:
0. A C program consists of a sequence of statements which are executed
one after the other.
A;
B;
C;
will run first A, then B, then C. Blocks of such sequences, wrapped
in {}, can usually each be considered equivalent to a single
statement.
This is very naive and also wrong. it can not be considered anything of
the kind. It is a scope. In that block anything could or could not be
executed.
>
1. You can print the value of an int variable named i with
printf("%i", i);
2. You can print a space with
printf(" ");
3. You can print a newline with
printf("\n");
4. You can do some sequence of things once for each value of i between
0 and 7 inclusive with
for (i = 0; i < 7; i++) {
E;
F;
G;
}
You could also have conditional if/else flows.
>
Now, the new bits:
5. You can calculate a new value by writing an arithmetic expression
involving variables, so for example to get the value of i plus 3,
i + 3
or, to get the value of i multiplied by i
i * i
6. You don't have to store such a value anywhere explicitly - you can
use it almost anywhere you could use the name of a variable, and then
instead of the value of the variable being used you'll use the new
calculated value. For example, you can print the value of an i plus 3
with
printf("%i", i+3);
(compare this with (1) above). You _can_ store a calculated value if
you want but we'll worry about that later.
So: since the variable i holds the line number that the question asks
for, how could you calculate the square of the line number? How could
you print that new value? What about the cube?
If you think you can answer the 3 questions above, try modifying the
program you posted here to complete the answer to q4a.
mlp
--
Bill Cunningham wrote:
>
Well here's my latest attempt. I just get the line numbers.
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" ,
i*i*i);
}
}
You really are priceless Bill! Replace that printf statement of yours
with the sequence I give below:
printf("%i\t", i);
printf("%i\t", i*i);
printf("%i\n", i*i*i);
Can you understand this? Until you understand what the three statements
above do, do *not* proceed further.
"Bill Cunningham" <no****@nspam.comwrote in message
news:%e8kk.456$Ht4.1@trnddc01...
>
Well here's my latest attempt. I just get the line numbers.
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
}
}
You are a C expert.
Richard<rg****@gmail.comwrites:
Mark L Pappin <ml*@acm.orgwrites:
[...]
>It'll do. Whatever options you used to run indent, keep using them.
Better don't. Do it by hand. Understand how to indent your own
code. programming, like building a wall, requires skill and pride in
ones work. Recommending "indent" is like recommending an automatic code
generator IMO. If Bill isnt a troll and he just types in any old rubbish
and then expects tools to make it readable only when he posts here then
he has no pride in his work and, frankly, no chance of ever cutting the
mustard.
I disagree. If he gets used to the way his code looks after it's been
run through indent, it's likely (well, possible anyway) that he'll
start writing it that way in the first place. In the meantime, it
gives him one less thing to worry about, which in his case would seem
to be a good idea.
[...]
>0. A C program consists of a sequence of statements which are executed one after the other. A; B; C; will run first A, then B, then C. Blocks of such sequences, wrapped in {}, can usually each be considered equivalent to a single statement.
This is very naive and also wrong. it can not be considered anything of
the kind. It is a scope. In that block anything could or could not be
executed.
No, it's quite correct. A block is a statement. See C99 6.8.2.
[...]
>4. You can do some sequence of things once for each value of i between 0 and 7 inclusive with for (i = 0; i < 7; i++) { E; F; G; }
You could also have conditional if/else flows.
Yeah, and while loops, and do-while loops, and gotos, and switch
statements, and longjmp(), and ....
Do you really think that piling on more details is helpful?
[...]
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Bill Cunningham" <no****@nspam.comwrote in message
news:%e8kk.456$Ht4.1@trnddc01...
>
Well here's my latest attempt. I just get the line numbers.
for (i = 0; i < 7; i++)
{
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
}
}
If you have yet to learn Programming, then C probably isn't the best choice
to start with. Try BASIC instead.
It will do everything you appear to want to do in C, eg:
10 FOR I=0 TO 6
20 PRINT I, I*I, I*I*I
30 NEXT I
But if battling with C is just a kind of therapy, then carry on.
--
Bartc
"Keith Thompson" <ks***@mib.orgschreef in bericht
news:ln************@nuthaus.mib.org...
I disagree. If he gets used to the way his code looks after it's been
run through indent, it's likely (well, possible anyway) that he'll
start writing it that way in the first place. In the meantime, it
gives him one less thing to worry about, which in his case would seem
to be a good idea.
It also helps that his questions dont get sidetracked in endless indentation
debates.
Its mad fun seeing a doped up guy learning C!
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:GO******************************@bt.com...
I have to hand it to you. That's a masterpiece.
Indeed it is Richard. Unfortunately.
Bill
ps sad isn't it. I don't know what to do.
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@registered.motzarella.org...
You really are priceless Bill! Replace that printf statement of yours
with the sequence I give below:
printf("%i\t", i);
printf("%i\t", i*i);
printf("%i\n", i*i*i);
Can you understand this? Until you understand what the three statements
above do, do *not* proceed further.
Well yeah I understand what that does above but the way it was put it
have to be on the same line.
Bill
"Bill Cunningham" <no****@nspam.comwrote in message
news:%e8kk.456$Ht4.1@trnddc01...
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
^ ^ ^ ^ ^ ^ ^
^
Caret 1. points to format specifier
Caret 2. space
Caret 3. format specifier
Caret 4. square
Caret 5. format specifier
Caret 6. space
Caret 7. format specifier
Caret 8. i cubed.
All this I didn't realize to not be on the same space. You said 3 lines so
the \n character 3 times.
Please remember Mark that... Well I don't know if you know or not but
you should so I will speak. My mind is half gone. In that I mean
concentration is limited. I'm on about 6 psychotropics legally for mentall
illness.
I also thought you meant 3 lines printed so that's why the 3 \n
specifiers.
Bill
Also I do have K&R2. FYI
Bill
Mark,
I appreciate everyone who cares' involvement in this but giving me the
answers like Santosh did below might not be best. If we would've talked I
probably would've figured it out but now Santosh gave me the answer. Do you
agree that others' input should be hints and not answers ?
Bill
Mark,
I appreciate your help but please understand, in dealing with me you will
need patience. Because of my limitations and I do have k&r2.
Bill
How about this. I don't know if the source is what you wanted, but the
binary does what I think you're looking for.
#include <stdio.h>
int
main (void)
{
int i;
for (i = 0; i < 7; i++)
{
printf ("%i", i);
printf (" ");
printf ("%i", i * i);
printf (" ");
printf ("%i", i * i * i);
printf ("\n");
}
return 0;
}
Bill
Bill Cunningham said:
<snip>
printf ("%i", i);
printf (" ");
printf ("%i", i * i);
printf (" ");
printf ("%i", i * i * i);
printf ("\n");
That will work, but I suggest you look closely at K&R2, page 9. Look
specifically at the program that occupies the upper half of the page. More
specifically, look at the loop. More specifically still, look at the
printf call inside that loop. What do you notice about the format string?
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:mL******************************@bt.com...
That will work, but I suggest you look closely at K&R2, page 9. Look
specifically at the program that occupies the upper half of the page. More
specifically, look at the loop. More specifically still, look at the
printf call inside that loop. What do you notice about the format string?
It's a while loop Richard and the format specifier is a tab. I would
have to go back and read Mark's question but I don't remember anything about
a tab. He said spaces.
Bill
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
<OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Bill
"Mark L Pappin" <ml*@acm.orgwrote in message
news:87************@Don-John.Messina...
Bill Cunningham Writes:
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
^ ^ ^ ^ ^ ^ ^
^
Caret 1. points to format specifier
Caret 2. space
Caret 3. format specifier
Caret 4. square
Caret 5. format specifier
Caret 6. space
Caret 7. format specifier
Caret 8. i cubed.
All this I didn't realize to not be on the same space. You said 3 lines so
the \n character 3 times.
Please remember Mark that... Well I don't know if you know or not but
you should so I will speak. My mind is half gone. In that I mean
concentration is limited. I'm on about 6 psychotropics legally for mentall
illness.
I also thought you meant 3 lines printed so that's why the 3 \n
specifiers.
Bill
"Bill Cunningham" <no****@nspam.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
<OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Try it and find out, and/or read the documentation.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Bill Cunningham said:
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:mL******************************@bt.com...
That will work, but I suggest you look closely at K&R2, page 9. Look
>specifically at the program that occupies the upper half of the page. More specifically, look at the loop. More specifically still, look at the printf call inside that loop. What do you notice about the format string?
[...] the format specifier is a tab.
No, it isn't - or at least, not *just* a tab.
I would
have to go back and read Mark's question but I don't remember anything
about a tab. He said spaces.
Forget the tab. What *else* do you notice about it? Hint: count the % signs
and the number of parameters coming after the format string.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Jul 31, 8:28*am, Keith Thompson <ks...@mib.orgwrote:
...
<OT>Try "indent -kr".</OT>
Will some code beautifiers be better?
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:md******************************@bt.com...
[snip]
Forget the tab. What *else* do you notice about it? Hint: count the %
signs
and the number of parameters coming after the format string.
There are 2 % one for each variable. But that's not what's confusing me
here. It's the , 's and the number of commas and where they all go. Commas I
see and not in the format specification at all. But there are commas
separating the variables.
Bill
Bill Cunningham wrote:
"Keith Thompson" <ks***@mib.orgwrote:
><OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Read the docs that came with it.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Bill Cunningham wrote:
>
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@registered.motzarella.org...
>You really are priceless Bill! Replace that printf statement of yours with the sequence I give below:
printf("%i\t", i); printf("%i\t", i*i); printf("%i\n", i*i*i);
Can you understand this? Until you understand what the three statements above do, do *not* proceed further.
Well yeah I understand what that does above but the way it was put
it have to be on the same line.
Then:
printf("i = %i\ti^2 = %i\ti^3 = %i\n", i, i*i, i*i*i);
Can you understand the above?
Bill Cunningham wrote:
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:md******************************@bt.com...
[snip]
>Forget the tab. What *else* do you notice about it? Hint: count the % signs and the number of parameters coming after the format string.
There are 2 % one for each variable. But that's not what's confusing
me here. It's the , 's and the number of commas and where they all go.
Commas I see and not in the format specification at all. But there are
commas separating the variables.
Each argument in a function call needs to be separated by a comma. The
first argument to printf (and the only mandatory argument) is the
format string itself (i.e., the "blahblah" thing). The subsequent
arguments are needed only if the format string (the first argument)
contains any conversion specifiers (i.e., a % character, example %i
etc.).
So in this printf call:
printf("hello");
there is only one argument, one that is mandatory, the string
literal "hello". No more arguments are needed because this string
literal does not have any conversion specifiers.
In this call:
printf("hello %s", "hello");
there are two arguments separated by the comma, both of them string
literals. There are two arguments because the first argument, the
format string, contains a conversion specifier %s. Whenever you have a
conversion specifier printf will expect a corresponding additional
argument to convert and print (omitting unneccessary complications
here). The %s conversion specifier expects a char* argument that points
to a string. A string literal serves perfectly.
Similarly:
printf("%d %d %d", a, b, c);
Answer these questions concerning the above statement:
1.) How many arguments have we supplied to printf here? How did you
derive this answer?
2.) Identify the first argument. What's it called?
3.) Looking at the first argument alone, can you tell if printf will
expect further arguments? If so, how many? How did you determine this,
explain your reasoning?
Bill Cunningham wrote:
Mark,
I appreciate everyone who cares' involvement in this but giving me the
answers like Santosh did below might not be best. If we would've
talked I probably would've figured it out but now Santosh gave me the
answer. Do you agree that others' input should be hints and not
answers ?
This is a pubic group Bill. Anyone can post anything is response to you.
While we all understand your stated problems (and many even believe
it), still there is bound to occur a post or two that you may find
either unhelpful or confusing.
If you want to converse only with Mark then I suggest that you carry on
your tutorial through private mail.
"Bill Cunningham" <no****@nspam.comwrites:
Also I do have K&R2. FYI
Then start again:
- work through each of the exercises in Chapter 1
- do NOT move on to an exercise until you have successfully completed
the previous one
- when you have completed ALL of the exercises in Chapter 1
successfully, go back to the start of Chapter 1 and work through all
of the exercises AGAIN, without looking at your previous solutions to
those exercises, and again: only move on when you have COMPLETED each
- when you have completed ALL of the exercises in Chapter 1 for the
second time, look at your solutions side by side (kill some trees for
this), and compare them. If you think that your second attempt was
better than your first (remember, both versions have been successfully
completed), go back and work through Chapter 1 AGAIN, and do this
comparison again.
- when you're happy that you can solve all the questions posed in
Chapter 1 without hardship, and that you have tried several different
ways of doing so and have run out of "better" ideas, then move on to
Chapter 2 and follow EXACTLY the same process.
- when you have worked through all of the exercises in K&R2
sequentially and got several fully functioning answers for each one,
put all of those printouts and saved files into a locked filing
cabinet and do the whole thing again (including all of the little
internal loops)
- when you have worked through all of K&R2 twice and then some, you
_will_ be able to program in C (or you'll be able to fake it
convincingly, and honestly that'll do).
While working through these steps, feel free to post your code here
for critique or assistance - if you provide sufficient detail of what
you expect it to do and where its behaviour deviates from that, plus
details of the steps you've taken already to isolate the problem, then
people will be more inclined to help you.
But those people won't be me. I'm tired of dealing with you, Bill,
and I've decided that my sanity is worth more to me than your
amusement.
mlp
"Bill Cunningham" <no****@nspam.comwrites:
I appreciate everyone who cares' involvement in this but giving me
the answers like Santosh did below might not be best. If we would've
talked I probably would've figured it out but now Santosh gave me
the answer. Do you agree that others' input should be hints and not
answers ?
Bill, this is Usenet. I can't control what other people post, and if
your flailing about drives them to hand you the answer on a plate just
to make you shut up, there's nothing I can do about it. I'm trying to
structure the progression of these exercises so that each one builds
on what you've already demonstrated you can regurgitate - please tell
me as soon as possible if I've taken too big a step for you to follow
- for everybody's sake don't post some random crap and expect us to
believe it was a genuine attempt that you thought would solve the
problem. The horribly broken printf() call was almost enough to
convince me that you're a troll who's enjoying stringing me along.
In the last 24 hours you've produced a lot more verbiage without
saying much.
In another post you wrote:
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
>^ ^ ^ ^ ^ ^ ^
^
Caret 1. points to format specifier
No, it doesn't. There are tab characters involved there somewhere,
because the carets don't line up with anything meaningful in that
line. Make sure that your posts (including code) contain no tab
characters in future. And you managed to screw up the matching
between attributions and quoting depth. ... Ahh, this article got
posted several times.
....
You said 3 lines so the \n character 3 times.
No, I didn't say "3 lines". I said:
4a. Write a program to print 7 lines, each containing the line
number (start at 0), the square of the line number, and the cube of
the line number, separated by spaces.
I said "7 lines". Total.
Each of those 7 lines had to contain 3 things, separated by spaces.
Please remember Mark that... Well I don't know if you know or not
but you should so I will speak. My mind is half gone. In that I mean
concentration is limited. I'm on about 6 psychotropics legally for
mentall illness.
With all due respect Bill: I don't care. Some people and some
occupations are incompatible - I'm never going to be a gymnast, for
example, no matter how much I stamp my feet and say "I wanna".
Programming a computer requires mental activity - if yours is impaired
then you're at a disadvantage before you start. Unless you are truly
outstanding (and I've seen no evidence of that) you will remain
blocked here. Perhaps you need to find another hobby (I trust that
you've not been considering this as a career direction) - take up
building model ships out of toothpicks, or something.
If you believe that you are as extraordinary as you would need to be
to break through the shackles which so far seem to be binding you, see
my other followup, to your "K&R2" posting.
Apart from that, have a nice life. I'm done here.
mlp
"Bill Cunningham" <no****@nspam.comwrote in message
news:1gskk.523$iM5.434@trnddc07...
>
"Mark L Pappin" <ml*@acm.orgwrote in message
news:87************@Don-John.Messina...
Bill Cunningham Writes:
printf ("%i\n", i, " " , "%i\n", i*i, "%i\n" , " " , "%i\n" , i*i*i);
>^ ^ ^ ^ ^ ^ ^
^
Caret 1. points to format specifier
Caret 2. space
Caret 3. format specifier
Caret 4. square
Caret 5. format specifier
Caret 6. space
Caret 7. format specifier
Caret 8. i cubed.
All this I didn't realize to not be on the same space. You said 3 lines so
the \n character 3 times.
Please remember Mark that... Well I don't know if you know or not but
you should so I will speak. My mind is half gone. In that I mean
concentration is limited. I'm on about 6 psychotropics legally for mentall
illness.
What does your doctor say when you tell him that the medication your taking
for mental illness is making you mentally ill?
I also thought you meant 3 lines printed so that's why the 3 \n
specifiers.
santosh <sa*********@gmail.comwrote:
It still seems suspicious to me, but I may be making accusations without
clear evidence. In any case, regardless of the "msg-ID" issue, based on
an overall consideration of his posts to clc, I believe Bill C is a
troll. IMO of course.
Frankly, I don't see that it matters whether he is a troll, or someone
with a learning problem _and_ the accompanying bad attitude that means
he refuses to do something about his learning problem. Either way,
trying to help him is bad for both the newsgroup and Bill himself.
Richard
Hello Bill, List
On Jul 27, 9:30 pm, "Bill Cunningham" <nos...@nspam.comwrote:
printf("%i \n",i);
Hum. Now I didn't expect that. I expected the numbers to be printed
horizontally.
Read the follow URL's. I'm sure you can fix the issue after that. http://en.wikipedia.org/wiki/Printf http://www.pixelbeat.org/programming/format_specs.html
If, after that, you still can't deal with...
#include <stdio.h>
#include <stdlib.h>
#define MAX_LOOP 7
int main(void)
{
int i;
for(i=0;i<MAX_LOOP;i++)
{
if(i>=MAX_LOOP)
{
printf("%i\n",i);
return EXIT_SUCCESS;
}
printf("%i ",i);
}
return EXIT_FAILURE;
}
Rafael
On Aug 1, 6:43*am, soscpd <sos...@gmail.comwrote:
Hello Bill, List
On Jul 27, 9:30 pm, "Bill Cunningham" <nos...@nspam.comwrote:
*printf("%i \n",i);
Hum. Now I didn't expect that. I expected the numbers to be printed
horizontally.
Read the follow URL's. I'm sure you can fix the issue after that.
http://en.wikipedia.org/wiki/Printfh...mat_specs.html
If, after that, you still can't deal with...
#include <stdio.h>
#include <stdlib.h>
#define MAX_LOOP 7
int main(void)
* * {
* * * * int i;
* * * * for(i=0;i<MAX_LOOP;i++)
* * * * * * {
* * * * * * * * if(i>=MAX_LOOP)
* * * * * * * * * * {
* * * * * * * * * * * * printf("%i\n",i);
* * * * * * * * * * * * return EXIT_SUCCESS;
* * * * * * * * * * }
* * * * * * * * printf("%i ",i);
* * * * * * }
* * * * return EXIT_FAILURE;
* * }
Rafael
Ok... the isn't really necessary (but cut him off demand a
replacement with another =), but is harmless here.
#include <stdio.h>
#include <stdlib.h>
#define MAX_LOOP 7
int main(void)
{
int i;
for(i=0;i<MAX_LOOP;i++)
{
if(i==MAX_LOOP)
{
printf("%i\n",i);
return EXIT_SUCCESS;
}
printf("%i ",i);
}
return EXIT_FAILURE;
}
Rafael
"Richard Bos" <rl*@hoekstra-uitgeverij.nlwrote in message
news:48****************@news.xs4all.nl...
>
Frankly, I don't see that it matters whether he is a troll, or someone
with a learning problem _and_ the accompanying bad attitude that means
he refuses to do something about his learning problem. Either way,
trying to help him is bad for both the newsgroup and Bill himself.
Well, you can say that about a lot of situations. I feel you still need to
try. When I was posting some questions about arcane stuff, people constantly
said I was a troll. I was just trying to pin down my exact question. It took
an author of the K&R and Mr. Keith (the Other one) to finally satisfy my
quest for knowledge. I encourage people to try not to assume you know the
full scope of the question from a couple of first posts that you've seen a
million times; the poster might be trying to gather their ideas for the
FIRST time and not realize what a bunch of pedantic bastards you all are
(and I mean that in the way you think I mean it, but with a brotherly hug at
the end)
I have been very stubborn on issues in this group, over and over again, and
patience and consideration have helped me, And made me a nicer poster (not
that THAT will last ;))
You know what, I shouldn't even be posting this. I don't know even the back
story. Or anything about this Bill guy.
Oops.... I hit send... damn it!
Uuuuhh... where's the unsend button...
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@aioe.org...
Then:
printf("i = %i\ti^2 = %i\ti^3 = %i\n", i, i*i, i*i*i);
Can you understand the above?
Oh my goodness no. The carets look like exponents. That's about all I
get.
Bill
On Aug 1, 11:29*am, "Bill Cunningham" <nos...@nspam.comwrote:
"santosh" <santosh....@gmail.comwrote in message
news:g6**********@aioe.org...
Then:
*printf("i = %i\ti^2 = %i\ti^3 = %i\n", i, i*i, i*i*i);
Can you understand the above?
* * Oh my goodness no. The carets look like exponents. That's about all I
get.
Bill
Bill, the first parameter in printf is a string. Every character in it
will be printed unless it is an escape sequence or a format
placeholder (i.e. %i, which is for printing an integer). So, the %i is
not being printed, it will print i (the second argument) as an
integer. As for \t, that is a escape sequence which stands for the TAB
character.
Bill Cunningham wrote:
>
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@aioe.org...
>Then:
printf("i = %i\ti^2 = %i\ti^3 = %i\n", i, i*i, i*i*i);
Can you understand the above?
Oh my goodness no. The carets look like exponents. That's about
all I get.
Okay, let's start smaller. Do you understand this?
printf("number = %i", n);
Try the following questions.
1.) How many arguments does this call have? Explain your answer.
2.) How many arguments does printf expect? Consult your Ref. for this.
3.) What does this printf call do?
Mabden wrote:
"CBFalconer" <cb********@yahoo.comwrote in message
news:48***************@yahoo.com...
>Bill Cunningham wrote:
"Keith Thompson" <ks***@mib.orgwrote:
<OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Read the docs that came with it.
What about the rest of us. I'm not loading that program, I have no
help file. Now I want to know! Don't be an info-hog.
<rest snipped>
That response by CBFalconer was, I'm pretty sure, specifically tailored
for Bill Cunningham, who has a habit of repeatedly asking trivial
questions even after they have been answered multiple times, and not
bothering to consult his system documentation.
Besides usage of 'indent' is not topical here. It may be topical in
gnu.misc.discuss or gnu.utils.help (if it is GNU indent) or
comp.unix.misc or comp.programming.
santosh said:
Mabden wrote:
>"CBFalconer" <cb********@yahoo.comwrote in message news:48***************@yahoo.com...
>>Bill Cunningham wrote: "Keith Thompson" <ks***@mib.orgwrote:
<OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Read the docs that came with it.
What about the rest of us. I'm not loading that program, I have no help file. Now I want to know! Don't be an info-hog.
<rest snipped>
That response by CBFalconer was, I'm pretty sure, specifically tailored
for Bill Cunningham, who has a habit of repeatedly asking trivial
questions even after they have been answered multiple times, and not
bothering to consult his system documentation.
Besides usage of 'indent' is not topical here. It may be topical in
gnu.misc.discuss or gnu.utils.help (if it is GNU indent) or
comp.unix.misc or comp.programming.
What's more, it's pretty easy to *guess* what -kr would do, isn't it? For
example, I didn't know, but I guessed, and then I looked it up, and I
discovered that my guess was correct.
Rocket science, it isn't.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Aug 1, 7:07 pm, santosh <santosh....@gmail.comwrote:
Mabden wrote:
"CBFalconer" <cbfalco...@yahoo.comwrote in message
news:48***************@yahoo.com...
Bill Cunningham wrote:
"Keith Thompson" <ks...@mib.orgwrote:
<OT>Try "indent -kr".</OT>
What's -kr do Keith ?
Read the docs that came with it.
What about the rest of us. I'm not loading that program, I have no
help file. Now I want to know! Don't be an info-hog.
<rest snipped>
That response by CBFalconer was, I'm pretty sure, specifically tailored
for Bill Cunningham, who has a habit of repeatedly asking trivial
questions even after they have been answered multiple times, and not
bothering to consult his system documentation.
Besides usage of 'indent' is not topical here. It may be topical in
gnu.misc.discuss or gnu.utils.help (if it is GNU indent) or
comp.unix.misc or comp.programming.
Mabden is a troll... please don't reply to him (and other trolls)
"Bill Cunningham" <no****@nspam.comwrites:
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@registered.motzarella.org...
>You really are priceless Bill! Replace that printf statement of yours with the sequence I give below:
printf("%i\t", i); printf("%i\t", i*i); printf("%i\n", i*i*i);
Can you understand this? Until you understand what the three statements above do, do *not* proceed further.
Well yeah I understand what that does above but the way it was put it
have to be on the same line.
They have to be on the same *output* line, not necessarily on the same
line in your program.
This:
printf("Hello, ");
printf("world\n");
is two lines in a program; it produces a single line of output.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Nigel" <ni***********@gmail.comwrote in message
news:c0**********************************@k37g2000 hsf.googlegroups.com...
Bill, the first parameter in printf is a string. Every character in it
will be printed unless it is an escape sequence or a format
placeholder (i.e. %i, which is for printing an integer). So, the %i is
not being printed, it will print i (the second argument) as an
integer. As for \t, that is a escape sequence which stands for the TAB
character.
Will the = be printed ? I understand the first parameter passed to
printf is a string. But I keep thinking that everything in quotes is
printed except what begins with %.
Bill vi******@gmail.com wrote:
On Aug 1, 7:07 pm, santosh <santosh....@gmail.comwrote:
>Mabden wrote:
"CBFalconer" <cbfalco...@yahoo.comwrote in message news:48***************@yahoo.com... Bill Cunningham wrote:
"Keith Thompson" <ks...@mib.orgwrote:
><OT>Try "indent -kr".</OT>
What's -kr do Keith ?
>Read the docs that came with it.
What about the rest of us. I'm not loading that program, I have no
help file. Now I want to know! Don't be an info-hog.
<rest snipped>
That response by CBFalconer was, I'm pretty sure, specifically tailored for Bill Cunningham, who has a habit of repeatedly asking trivial questions even after they have been answered multiple times, and not bothering to consult his system documentation.
Besides usage of 'indent' is not topical here. It may be topical in gnu.misc.discuss or gnu.utils.help (if it is GNU indent) or comp.unix.misc or comp.programming.
Mabden is a troll... please don't reply to him (and other trolls)
Okay, I'll take your word for it, since these are the first posts to
this group by 'Mabden' that I'm noticing.
"santosh" <sa*********@gmail.comwrote in message
news:g6**********@registered.motzarella.org...
Okay, let's start smaller. Do you understand this?
printf("number = %i", n);
Try the following questions.
1.) How many arguments does this call have? Explain your answer.
2.) How many arguments does printf expect? Consult your Ref. for this.
3.) What does this printf call do?
Sure I understand that one. number= and the value of n will be printed.
Yes that's easy.
There's an ... elipses in the parameter. I think that might mean several
arguments.
Bill
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrites:
On Jul 31, 8:28*am, Keith Thompson <ks...@mib.orgwrote:
...
><OT>Try "indent -kr".</OT>
Will some code beautifiers be better?
Do you mean better than "indent -kr"? Better in what sense?
If I undrestand your question correctly, there is no definitive answer
to it -- and if there were, I doubt that it would be topical here.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Richard Bos wrote:
santosh <sa*********@gmail.comwrote:
It still seems suspicious to me, but I may be making accusations
without clear evidence. In any case, regardless of the "msg-ID"
issue, based on an overall consideration of his posts to clc, I
believe Bill C is a troll. IMO of course.
Frankly, I don't see that it matters whether he is a troll, or someone
with a learning problem and the accompanying bad attitude that means
he refuses to do something about his learning problem. Either way,
trying to help him is bad for both the newsgroup and Bill himself.
This is kind of where I am with it. Either he's trolling or
legitimately learning disabled. He either is pretending not to learn
anything, or incable of learning. So it's a waste of time to pursue
this.
He's supposedly been learning C for YEARS. And no farther along than
this. You'd except an average student to show more progress after a few
weeks of study than Bill demonstrates.
Brian
Bill Cunningham wrote:
>
"Nigel" <ni***********@gmail.comwrote in message
news:c0**********************************@k37g2000 hsf.googlegroups.com...
>
Bill, the first parameter in printf is a string. Every character in it
will be printed unless it is an escape sequence or a format
placeholder (i.e. %i, which is for printing an integer). So, the %i is
not being printed, it will print i (the second argument) as an
integer. As for \t, that is a escape sequence which stands for the TAB
character.
Quotes messed up again Bill? ;-)
Will the = be printed ? I understand the first parameter passed to
printf is a string. But I keep thinking that everything in quotes is
printed except what begins with %.
Characters in the printf format string other than escape sequences,
conversion specifiers, trigraph and digraph sequences are written
without any processing to stdout. A conversion specifier begins with a
percent character and escape sequences are introduced with a backslash.
You needn't worry about digraphs and trigraphs yet. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Canonical Latin |
last post by:
"Leor Zolman" <leor@bdsoft.com> wrote
> "Canonical Latin" <javaplus@hotmail.com> wrote:
>
> > ...
> >But I'm still curious as to the rational of having type
>...
|
by: Matteo Settenvini |
last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using
g++ 3.3.x.
I had been taught that an array isn't a lot different from a pointer
(in fact you can use the pointer arithmetics to...
|
by: JezB |
last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of
files that match one of 3 search patterns, so I need something like
DirectoryInfo ld = new DirectoryInfo(searchDir);...
|
by: Michel Rouzic |
last post by:
It's the first time I try using structs, and I'm getting confused with
it and can't make it work properly
I firstly define the structure by this : typedef struct { char *l1; int
*l2; int Nval; }...
|
by: Rob Griffiths |
last post by:
Can anyone explain to me the difference between an element type and a
component type?
In the java literature, arrays are said to have component types, whereas
collections from the Collections...
|
by: Rene Nyffenegger |
last post by:
Hello everyone.
I am not fluent in JavaScript, so I might overlook the obvious.
But in all other programming languages that I know and that
have associative arrays, or hashes, the elements in...
|
by: Robert Bravery |
last post by:
Hi all,
Can some one show me how to achieve a cross product of arrays. So that if I
had two arrays (could be any number) with three elements in each (once again
could be any number) I would get:...
|
by: Doug_J_W |
last post by:
I have a Visual Basic (2005) project that contains around twenty
embedded text files as resources. The text files contain two columns
of real numbers that are separated by tab deliminator, and are...
|
by: mike3 |
last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms-
windows.programmer.win32
since there's Windows material in here as well as questions related to
standard
C++. Not sure how that'd go over...
|
by: weaknessforcats |
last post by:
Arrays Revealed
Introduction
Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with
arrays and array syntax but is not clear on a )exactly how...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |