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

  • SEARCH
  • Home
  • 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 6797231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:35:02+00:00 2026-05-26T18:35:02+00:00

I am trying to work on a program where the user enters a random

  • 0

I am trying to work on a program where the user enters a random number and the program enters a list from 0 to 9.

For example, say that the user enters the number 12 then the screen should look like this:

0123456789012

Where ‘2’ at the end indicates the 12th number. I’ve tried this but it gives me an infinite loop and I don’t know how to tell it to stop:

for(i = 0; i < cells; i++) {
i = i%10;
printf("%d", i);
}

The cells here is the number that the user enters.

  • 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-05-26T18:35:02+00:00Added an answer on May 26, 2026 at 6:35 pm

    The problem is that you are changing i in the loop. You must iterate as many times as the input. You’re almost there, but you loop forever because you are modifying i in such a way that it will never be larger than or equal to cells for cells > 10.

    Try this:

    for( int i = 0; i < cells; ++i ) {
        printf( "%d", i % 10 );
    }
    

    Also…

    0123456789012

    Where ‘2’ at the end indicates the 12th number.

    The second 2 is the 13th number, not the 12th 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate that the input a user gives my program via gets
I am trying to run a program that asks for a number and the
I'm trying to get input from user using array of structs and then print
I am trying to make a program to work on top of an existing
I'm trying to get this simple program to work on windows, but it crashes:
Trying to work with groupby so that I can group together files that were
Weve recently been trying to work on an application that uses pandastream to encode
I'm trying to do some processing on whether the user enters a (1) file
For my program, I am trying to assist the user, and reduce his or
I'm trying to develop a new program. The work flow looks like this: Login

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.