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 solve them using for loop......


thankyou very much for solving my problem...
 
V

Victor Bazarov

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

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


2) abcdefgfedcba
abcdefedcba
abcdedcba
abcdcba
abcba
aba
a

please solve them using for loop......


thankyou very much for solving my problem...

#include <iostream>

int main() {
const char* foo[] = {
"1) *\n"
" * *\n"
" * * *\n"
" * * * *\n"
" * * *\n"
" * *\n"
" *\n\n\n"
,
"2) abcdefgfedcba\n"
" abcdefedcba\n"
" abcdedcba\n"
" abcdcba\n"
" abcba\n"
" aba\n"
" a\n\n" };

for (int k = 0; k < 1; ++k)
for (int j = 0; j < 1; ++j)
for (int i = 0; i < sizeof(foo)/sizeof(foo[0]); ++i)
std::cout << foo;
}

There are for loops and the output should be exactly as you asked.

You're welcome!

Oh, and check out

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

for more information on your inquiry.

V
 
A

Alf P. Steinbach

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

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


2) abcdefgfedcba
abcdefedcba
abcdedcba
abcdcba
abcba
aba
a

please solve them using for loop......


thankyou very much for solving my problem...

Huh? What was wrong with the earlier answers?
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top