?
Solved

two for loops

Posted on 2003-03-26
6
Medium Priority
?
236 Views
Last Modified: 2010-04-01
i'm trying to use two for loops to create the following output

0
01
012
0123
01234
012345
0123456
0
Comment
Question by:asthetic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:prady_21
ID: 8209166
#include<stdio.h>
#define n 10
int main(void)
{
     int i, j;

     for ( i = 0; i < n ; i++ ) {
        for ( j = 0 ; j< i; j++ ) {
          printf("%d ", j);
        }
        printf("\n");
     }
}

This should work
0
 
LVL 1

Accepted Solution

by:
ivec earned 150 total points
ID: 8209291
More precisely, and in C++:

#include<iostreams>

int main(void)
{
  const maxDigitValue = 6;
  for( int row = 0 ; row <= maxDigitValue ; ++row )
  {
    for( int digit = 0 ; digit <= row ; ++digit )
      std::cout << digit;
    std::cout << std::endl;
  }
}
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8209307
>> i'm trying to use two for loops to create the following output

Nice goin'.... people don't even ask for codes, but they get the entire codes!!

Mayank.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:Salte
ID: 8209580
Mayank,

dare we say the 'h' word again?

Alf
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8209589
No, buddy.... ha ha :-))

Mayank.
0
 
LVL 3

Expert Comment

by:prady_21
ID: 8209598
Well i have seen people posting codes and the results as well. They are ready to do home works for others ???
I dont know what to say for that.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question