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 7859435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:54:32+00:00 2026-06-02T21:54:32+00:00

So the assignment is to ask for a variable in a certain range the

  • 0

So the assignment is to ask for a variable in a certain range the print the individual digits of the numbers with three spaces in between the digit. For example 1234 should print

0 1 2 3 4
1 2 3 4
2 3 4
3 4 
4

I’m pretty sure I have most of the assignment done I am just having trouble changing the variable number in my loop. The number sorts itself into the right if statement but then when it loops instead of the number going down a digit (i.e. 2343 to 343) all it does is print the same number 5 times. I have researched in my book and looked online but i’m not seeing it. It’s probably something simple just not sure what. Here’s the code:

#include <stdio.h>
#include <stdlib.h>
void loopingDigitprinter(int digit);
int division(int* digit);

int main() 
{
    int digitPrint;



    printf("Please enter a number between 0 and 32,767: ");
    scanf("%d", &digitPrint);
    loopingDigitprinter (digitPrint);

    return 0;
}

void loopingDigitprinter(int digit)
{
    int loopLine= 0;
   int thousand;
   int hundred;
   int original;
   original = digit;



    while(loopLine < 4)
    {
        if (digit > 10000 && digit <= 32767)
            {
                thousand = digit/ 1000;
                hundred = digit % 1000;
                printf("%02d%03d\n",thousand, hundred);
                digit %= 10000;


            }
        else if (digit < 10000 && digit > 1000)
            {

              if (original > 10000)
                    {   thousand = digit/ 1000;
                        hundred = digit % 1000;
                        digit %= 1000;
                        printf("%01d%03d\n",thousand, hundred);
                    }
            else
                    {
                        thousand = digit/ 1000;
                        hundred = digit % 1000;
                        printf("%02d%03d\n",thousand, hundred);
                        digit %= 1000;
                    }

            }
         else if (digit < 1000 && digit > 100)
            {
                if (original > 10000)
                    {
                         hundred = digit % 1000;
                         printf("%d\n",  hundred);
                         digit %= 100;
                    }  
                 else if (original < 10000 && original > 1000)
                    {
                        thousand = original / 1000;
                        hundred = digit % 1000;
                        printf("%d%d\n",thousand,digit);
                        printf("%d\n", digit);
                        digit %= 100;
                        digit %= 100;

                    }
                else
                    {
                         thousand = digit/ 1000;
                        hundred = digit % 1000;
                         printf("%02d%03d\n",thousand, hundred);
                        digit %= 1000;
                         thousand = original / 1000;
                         hundred = digit % 1000;
                         printf("%d%d\n",thousand,digit);
                         printf("%d\n", digit);
                         digit %= 100;
                         printf("%d\n", digit);
                         digit %= 10;
                         printf("%d\n", digit);
                     }

             }
         else if (digit < 100 && digit > 10)
            {
                if (original > 10000)
                     {   hundred = digit % 1000;
                         printf("%d\n", hundred);
                         digit %= 10;
                         printf("%d\n", digit);
                     }
                 else if (original < 10000 && original > 1000)
                     {
                         thousand = original / 1000;
                         hundred = digit % 1000;
                         printf("%d\n",hundred);
                         digit %= 10;
                        printf("%d\n", digit);
                    }
                 else if (original < 1000 && original > 10)
                    {
                        thousand = digit/ 1000;
                        hundred = digit % 1000;
                        printf("%02d%03d\n",thousand, hundred);
                        digit %= 1000;
                        thousand = original / 1000;
                        hundred = digit % 1000;
                        printf("%d%03d\n",thousand,digit);
                        printf("%03d\n", digit);
                        digit %= 100;
                        printf("%d\n", digit);
                        digit %= 10;
                        printf("%d\n", digit);

                    }
                else
                   printf("1");
               }

        else if(original > 0 && original < 10)

            {
                 printf("0000%d\n", original);
                 printf("000%d\n", original);
                 printf("00%d\n", original);
                 printf("0%d\n", original);
                 printf("%d\n", original);
                break;
            }



         loopLine++;
        }

        return;
 }
  • 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-02T21:54:33+00:00Added an answer on June 2, 2026 at 9:54 pm

    I dont know what you are doing there as i did not read the code.

    But do refer to my sample code. It pretty much does the needful

    #include <stdio.h>
    #include <string.h>
    
    int main(int argc, char*argv[]){
    
    int n,k,i=0;
    
    printf("Enter a number please\n");
    scanf("%d",&n);
    
    while(i<=n){
    
        for(k=i;k<=n;k++){
    
            printf("%d ",k);
    
        }
    
        printf("\n");   
        i++;
    }
    
    return 0;
    }
    
    
    Output
    ------
    0 1 2 3 4
    1 2 3 4
    2 3 4
    3 4 
    4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My assignment requires that I have an ER diagram that shows the dependencies between
Does an assignment of a real to a variable starting with I convert to
So I have a assignment ask me to use randomized quick sort, and I
If x exists, then print x exists. I ask this because I always get
I have an assignment where I have questions that ask for the following implementations:
My assignment ask to make a function call readFasta that accepts one argument: the
Assignment of NSFileOwnerAccountName and NSFileGroupOwnerAccountName does not work? The directory created defaults to my
The assignment at my first year uni computing course says my program should read
I have an assignment to create a GUI using MATLAB GUIDE and am having
I have an assignment about fftw and I was trying to write a small

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.