Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:59:15+00:00 2026-06-13T16:59:15+00:00

Hello wrote a program that outprints this; 0 01 012 0123 01234 012345 01234

  • 0

Hello wrote a program that outprints this;

0

01

012

0123

01234

012345

01234

0123

012

01

0

Im pretty sure my method is long and stupid, heres how it looks like

#include <stdio.h>

int main(void)
{

int first = -1, second = -1, third = -1, fourth = -1, fifth = -1, sixth = -1, seventh = -1, eight = -1, nine = -1, ten = -1, elleven = -1;

while(first < 0){
first += 1; 
printf("%d\n", first);

while(second < 1){
second += 1;
printf("%d", second);
}
printf("\n");
while(third < 2 ){
third += 1;
printf("%d", third);
}
printf("\n");
while(fourth < 3){
fourth += 1;
printf("%d", fourth);
}
printf("\n");
while(fifth < 4){
fifth += 1;
printf("%d", fifth);
}
printf("\n");
while(sixth < 5){
sixth += 1;
printf("%d", sixth);
}
printf("\n");
while(seventh < 4){
seventh += 1;
printf("%d", seventh);
}
printf("\n");
while(eight < 3){
eight += 1;
printf("%d", eight);
}
printf("\n");
while(nine < 2) {
nine += 1;
printf("%d", nine);
}
printf("\n");
while(ten < 1){
ten += 1;
printf("%d", ten);
}
printf("\n");
while(elleven < 0){
elleven += 1;
printf("%d", elleven); 
}
}

return 0;
}

if anyone would be kind enough to show me how to do this easier? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:59:16+00:00Added an answer on June 13, 2026 at 4:59 pm

    Well, I notice that you have a string whose length varies from 1 to 6, and then back, containing the symbols from 0 to its length excluded.

    So we can do this with two loops, one ascending, one descending, both nested to get all symbols.

        int i, j;
    
        for (i = 0; i < 6; i++)
        {
                for (j = 0; j <= i; j++)
                        printf("%d", j);
                printf("\n");
        }
        for (i = 5; i > 0; i--)
        {
                for (j = 0; j < i; j++)
                        printf("%d", j);
                printf("\n");
        }
    

    The second for may be replaced with while(--i), since i starts from the end of the previous cycle.

    Output:

    0
    01
    012
    0123
    01234
    012345
    01234
    0123
    012
    01
    0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a program called Hello.py that looks like this: import pygame, sys from
I wrote this small C++ program and built it(Release) #include<iostream> int main(){ std::cout<<Hello World;
I wrote a program that reverses each word in a string. For example hello
I wrote a simple c++ program that prints Hello World! #include <iostream> using namespace
I wrote a very simple program named test.py which looks like this: print 'hello
I just started learning C, and wrote my hello world program: #include <stdio.h> main()
I just started learning C, and wrote my hello world program: #include <stdio.h> main()
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Problem: I wrote a hello world java program, compiled and created a jar file
I wrote a simple hello world program to test the JDK installation. I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.