Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

two for loops

i'm trying to use two for loops to create the following output

0
01
012
0123
01234
012345
0123456
0
asthetic
Asked:
asthetic
1 Solution
 
prady_21Commented:
#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
 
ivecCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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.

 
SalteCommented:
Mayank,

dare we say the 'h' word again?

Alf
0
 
Mayank SAssociate Director - Product EngineeringCommented:
No, buddy.... ha ha :-))

Mayank.
0
 
prady_21Commented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now