looping problems

T

tanmay

please tell me how to get the following output using loops...

1) *
* *
* * *
* * * *
* * *
* *
*


2) abcdefgfedcba
abcdefedcba
abcdedcba
abcdcba
abcba
aba
a
please do use "for" loop.

thankyou very much for solving my problem...
 
T

tanmay

well i am using turbo c++ compiler....
do remember to use for loop.......
and plese suggest me a nice e-book or refrence book for java
language.....

thanks!!
 
V

Victor Bazarov

tanmay said:
well i am using turbo c++ compiler....
do remember to use for loop.......
and plese suggest me a nice e-book or refrence book for java
language.....

Please go to a Java newsgroup to ask about books on Java.
 
A

Alf P. Steinbach

* tanmay:
well i am using turbo c++ compiler....
do remember to use for loop.......
and plese suggest me a nice e-book or refrence book for java
language.....

thanks!!

troll go away
 
T

tanmay

Hello,

I think that nobody here want to do your homework.

Markus

well as u said ..let me clarify....
i am learning c++ as a part of my hobby...and i am not consulting any
teacher......well i had problem which i thought would be clarified
here.....
so thats why i joined this group...thinking you people will help me
out in learning...
sir,sorry to say,but instead of writing all this...i would have really
appriciated if you would have answered my query...as its very easy for
you....
 
V

Victor Bazarov

tanmay said:
well as u said ..let me clarify....
i am learning c++ as a part of my hobby...and i am not consulting any
teacher......well i had problem which i thought would be clarified
here.....

What problems are those? What needs to be "clarified"? Can you be
specific, please?
so thats why i joined this group...thinking you people will help me
out in learning...

Doing your tasks *for* you is not helping you out in learning.
sir,sorry to say,but instead of writing all this...i would have really
appriciated if you would have answered my query...as its very easy for
you....

Yes, it's easy for most of us here. But if you want it to become easy
for *you* as well, *you* need to do it *yourself*.

Imagine somebody wanting to learn to ride a bicycle. It's not going to
help him/her to see somebody else do it. He/she needs to *get on the
damn bicycle* and ride it. If you (as you claim) are learning C++ "as
part" of your "hobby" (and what hobby is that, I wonder?), you need to
start *writing those programs* yourself. Otherwise, don't call it
"learning".

V
 
R

Robert Bauck Hamar

tanmay said:
well as u said ..let me clarify....

I haven't seen any /u/ in this group. Whatever he/she said, I don't know it.

Please make an effort to use correct language. /You/ has three letters, and
they're not hard to type, and one dot is more than enough to end a
sentence. There are many readers here who have problems enough with the
English language, and many others don't even bother reading 'obfuscated
English'.
i am learning c++ as a part of my hobby...and i am not consulting any
teacher......

Whether it was you or your teacher who gave you your homework assignment
doesn't really matter. It's still homework.
well i had problem which i thought would be clarified
here.....

Sure. Try to do it yourself first.
so thats why i joined this group...thinking you people will help me
out in learning...

Many people here are happy to help. But you will not learn if you don't do
your homework yourself.
sir,sorry to say,but instead of writing all this...i would have really
appriciated if you would have answered my query...as its very easy for
you....

Indeed it is easy. However, we have better things to do than other people's
homework.
 
T

tanmay

What problems are those? What needs to be "clarified"? Can you be
specific, please?


Doing your tasks *for* you is not helping you out in learning.


Yes, it's easy for most of us here. But if you want it to become easy
for *you* as well, *you* need to do it *yourself*.

Imagine somebody wanting to learn to ride a bicycle. It's not going to
help him/her to see somebody else do it. He/she needs to *get on the
damn bicycle* and ride it. If you (as you claim) are learning C++ "as
part" of your "hobby" (and what hobby is that, I wonder?), you need to
start *writing those programs* yourself. Otherwise, don't call it
"learning".

V

thanks for showing your concern on the problem...well what comes into
my mind is that we ahave to apply 3 for loops for the first question
one for space,one for star,and third for the space on the right
side.....in the second part i can think at all....well i tried to use
ascii codes for a to f in a for loop making two for loop one
incrementing and the other decrementing......nd yes third loop for
endl.....now tell me what should i do....
thanks
 
J

jjds101

well as u said ..let me clarify....
i am learning c++ as a part of my hobby...and i am not consulting any
teacher......well i had problem which i thought would be clarified
here.....
Bullshit.

so thats why i joined this group...thinking you people will help me
out in learning...

Sure, we'll help you out in learning, if that's what your really
want. But all you're doing is posting a problem and expecting an
answer. If you really want to learn something, try it yourself.
sir,sorry to say,but instead of writing all this...i would have really
appriciated if you would have answered my query...as its very easy for
you....

And I'd really appreciate it if you'd stop using all of those dots in
your writing. And did your own homework.
 
T

tanmay

What problems are those? What needs to be "clarified"? Can you be
specific, please?


Doing your tasks *for* you is not helping you out in learning.


Yes, it's easy for most of us here. But if you want it to become easy
for *you* as well, *you* need to do it *yourself*.

Imagine somebody wanting to learn to ride a bicycle. It's not going to
help him/her to see somebody else do it. He/she needs to *get on the
damn bicycle* and ride it. If you (as you claim) are learning C++ "as
part" of your "hobby" (and what hobby is that, I wonder?), you need to
start *writing those programs* yourself. Otherwise, don't call it
"learning".

V

What problems are those? What needs to be "clarified"? Can you be
specific, please?


Doing your tasks *for* you is not helping you out in learning.


Yes, it's easy for most of us here. But if you want it to become easy
for *you* as well, *you* need to do it *yourself*.

Imagine somebody wanting to learn to ride a bicycle. It's not going to
help him/her to see somebody else do it. He/she needs to *get on the
damn bicycle* and ride it. If you (as you claim) are learning C++ "as
part" of your "hobby" (and what hobby is that, I wonder?), you need to
start *writing those programs* yourself. Otherwise, don't call it
"learning".

V

thanks for showing your concern on the problem...well what comes into
my mind is that we ahave to apply 3 for loops for the first question
one for space,one for star,and third for the space on the right
side.....in the second part i can't think at all....well i tried to
use ascii codes for a to f in a for loop making two for loop one
incrementing and the other decrementing......nd yes third loop for
endl.....now tell me what should i do....
thanks
 
V

Victor Bazarov

tanmay said:
[..]
well what comes into
my mind is that we ahave to apply 3 for loops for the first question
one for space,one for star,and third for the space on the right
side.....in the second part i can think at all....well i tried to use
ascii codes for a to f in a for loop making two for loop one
incrementing and the other decrementing......nd yes third loop for
endl.....now tell me what should i do....

OK. Here is what you *should* do: whatever "comes into" your mind,
put it in C++ terms. That would constitute another attempt. And
then *post* here what you "tried" (incrementing and decrementing, and
all that). Then, after proving to all of us (yes, I know, it's kind
of cruel that we need you to prove something to us, but life isn't
easy) that you are actually willing to make an effort, ask particular
questions about _your_ code. We will do our best to _correct_ it,
but we're not going to provide you with a working solution just for
a song.

V
 
O

osmium

Victor Bazarov said:
Imagine somebody wanting to learn to ride a bicycle. It's not going to
help him/her to see somebody else do it. He/she needs to *get on the
damn bicycle* and ride it. If you (as you claim) are learning C++ "as
part" of your "hobby" (and what hobby is that, I wonder?), you need to
start *writing those programs* yourself. Otherwise, don't call it
"learning".

Learning to ride a bicycle has nothing in common with learning to program.
Anyone that ever rode a bicycle can get on one and ride it after no bicycle
exposure for many years. As far as I can tell, if you can still walk, you
can still ride a bicycle. I can't even write a program in languages that I
used to be quite fluent in. I can kind of read them, but not write them
without a refresher.

I would be amazed if there are places that claim to teach one to ride a
bicycle.

Please, no more bicycle analogies.
 
V

Victor Bazarov

osmium said:
Victor Bazarov said:
Imagine somebody wanting to learn to ride a bicycle. It's not going
to help him/her to see somebody else do it. He/she needs to *get on
the damn bicycle* and ride it. If you (as you claim) are learning
C++ "as part" of your "hobby" (and what hobby is that, I wonder?),
you need to start *writing those programs* yourself. Otherwise,
don't call it "learning".

Learning to ride a bicycle has nothing in common with learning to
program. [..]

Please, no more bicycle analogies.

For you, anything.
 
S

Shadowman

tanmay said:
well as u said ..let me clarify....
i am learning c++ as a part of my hobby...and i am not consulting any
teacher......well i had problem which i thought would be clarified
here.....
so thats why i joined this group...thinking you people will help me
out in learning...
sir,sorry to say,but instead of writing all this...i would have really
appriciated if you would have answered my query...as its very easy for
you....
Really? That seems to contradict what you said here:

http://groups.google.com/group/alt....d8915/ae35f97f9f9b2a6a?hl=en#ae35f97f9f9b2a6a
 
T

tanmay

Really? That seems to contradict what you said here:

http://groups.google.com/group/alt.comp.lang.learn.c-c++/browse_threa...

--
SM
rot13 for email- Hide quoted text -

- Show quoted text -

hey what the contradiction.cant a comp. science engineer learn any
language by his own during vacations.its really dismal that some
people in here pay more importance to what really is unimportant.for
your kind information during my first year at enginnering i learnt
autocad and a little c language.its vacations now and i am learning c+
+ by my own.
any more problems to anyone.feel free to clarify.
 
M

Markus Pitha

tanmay said:
thanks for showing your concern on the problem...well what comes into
my mind is that we ahave to apply 3 for loops for the first question
side.....in the second part i can't think at all....well i tried to
use ascii codes for a to f in a for loop making two for loop one
incrementing and the other decrementing......nd yes third loop for
endl.....now tell me what should i do....
thanks


You problem has more to do with algorithmic thinking than programming in
c++.
First of all think about _every step_ you have to do to get these star
pattern.
Seceondly write it down with pseudo code.
At last, translate it to c++ code.


Markus
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

hey what the contradiction.cant a comp. science engineer learn any
language by his own during vacations.its really dismal that some
people in here pay more importance to what really is unimportant.for
your kind information during my first year at enginnering i learnt
autocad and a little c language.its vacations now and i am learning c+
+ by my own.
any more problems to anyone.feel free to clarify.

You claim to have learned some C, then the similarities between C and
C++ should be enough for you to be able to solve these problems, they
are not hard.
 
S

sumedh.....

int main()
{
int p=0;
int j,n;
printf("Enter n");
scanf("%d",&n);
j=n-1;
printf("\n\n");
printf("\t\t");
for(int p=0;p<2*n-1;p++)
{
for(int i=abs(j);i<n;i++)
printf("* ");
j--;
if(j>=0)
{
printf("\n\t\t");
int k=n-1-j;
while(k>0)
{printf("\b\b");k--;}
}
else
{
printf("\n\t\t");
int k=n-1-abs(j);
while(k>0)
{printf("\b\b");k--;}
}
}
}

happy programming..
lets discuss on complexity in this respect...
can anyone suggest how can the program be made more efficient..

....
Coding is not a big deal but efficiency is...
 
R

red floyd

sumedh..... said:
int main()
{
int p=0;
int j,n;
printf("Enter n");
scanf("%d",&n);
j=n-1;
printf("\n\n");
printf("\t\t");
for(int p=0;p<2*n-1;p++)
{
for(int i=abs(j);i<n;i++)
printf("* ");
j--;
if(j>=0)
{
printf("\n\t\t");
int k=n-1-j;
while(k>0)
{printf("\b\b");k--;}
}
else
{
printf("\n\t\t");
int k=n-1-abs(j);
while(k>0)
{printf("\b\b");k--;}
}
}
}

happy programming..
lets discuss on complexity in this respect...
can anyone suggest how can the program be made more efficient..

...
Coding is not a big deal but efficiency is...


I'd make the exact reverse argument. Given the poor indentation,
structure, variable names, and lack of comments, it's very difficult to
figure out what your program is supposed to do.

In the "Real World"(tm), programs aren't written and forgotten. They're
maintained by people, often people who didn't originally write them.
The coding style and readability/maintainability/scalability are much
more important than the sort of micro-optimization that you are asking
about.

Have you benchmarked this code to see if there's a bottleneck? How do
you know it's not "efficient"? For that matter, please define "efficient".
 

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,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top