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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:24:05+00:00 2026-05-26T14:24:05+00:00

In K.N Kings "C programming: A modern approach", chapter 10 exercise 7, the task

  • 0

In K.N Kings "C programming: A modern approach", chapter 10 exercise 7, the task is to make a digit converter from normal digits to 7-segment digits in ASCII art, like this:

   _   _        _   _   _   _   _   _ 
|  _|  _|  |_| |_  |_    | |_| |_| | |
| |_   _|    |  _| |_|   | |_|   | |_|

I got the sequence for each digit where to turn in it on and off

sample:

int digit_sequence[10][7] = {
    // A,B,C,D,E,F,G
    /* 0 */ {1,1,1,1,1,1,0}

}

Where 1 = ON, 0 = OFF

but I have a hard time getting the process_digit(int digit, int position) function to work.

I have a hard time in my head translating from sequence[10][7] to digits[4][MAX_DIGITS*4]

Could a kind soul please help me?

I have been reading the golf code seven-segment challenge, but even though I understand that theory it’s still hard to convince my brain into doing what I want with multiple arrays.


Ignoring the ASCII art, the question reads:

Write a program that prompts the user for a number and then displays the number using characters to simulate the effect of a seven-segment display.

…

Characters other than digits should be ignored. Write the program so that the maximum number of digits is controlled by a macro named MAX_DIGITS which has the value 10. If the number contains more than this number of digits, the extra digits are ignored. Hints: Use two external arrays. One is the segments array […] which stores data representing the correspondence between digits and segments. The other array, digits, will be an array of characters with 4 rows (since each segmented digit is 4 characters high) and MAX_DIGITS * 4 columns (digits are three characters wide but a spaces is needed between digits for readability). Write your program as four functions: main, […]

void clear_digits_array(void);
void process_figit(int digit, int position);
void print_digits_array(void);

clear_digits_array will store blank characters into all elements of the digits array. process_digit will store the seven-segment representation of digit into a specified position in the digits array (positions range from 0 to MAX_DIGITS - 1). print_digits_array will display the rows of the digits array, each on a single line […].

  • 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-26T14:24:05+00:00Added an answer on May 26, 2026 at 2:24 pm

    The trick is to map where a segment goes on display.

    The line number is the same for each segment.

    0:  _   _
    1: |_| |_| ...
    2: |_| |_|
    3:     
    

    However, the columns vary by position. Each position is a 4 characters width ‘mini-matrix’ (3 for segments and 1 for space: '|_| '). So we fix the line of segment and sum its column on the ‘mini-matrix’ with (position*4).

    0123 4567 89AB
     _    _    _
    |_|  |_|  |_|   ...
    |_|  |_|  |_|
    pos0 pos1 pos2
    

    Got it? The code will be something like that:

    void process_digit(int digit, int position){
        int i;
        for(i=0;i<7;i++){
            if(segments[digit][i]==1) /* Has digit the i segment? */
                switch(i){
                    case 0: digits[0][1+position*4]='_';break;
                    case 1: digits[1][2+position*4]='|';break;
                    case 2: digits[2][2+position*4]='|';break;
                    case 3: digits[2][1+position*4]='_';break;
                    case 4: digits[2][0+position*4]='|';break;
                    case 5: digits[1][0+position*4]='|';break;
                    case 6: digits[1][1+position*4]='_';break;
                }
        }
    }
    

    (You may choose between ‘-‘ and ‘_’, or perhaps change some lines)

    Hope it helps.

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

Sidebar

Related Questions

SELECT Y/X as Z FROM ( SELECT (count(county) FROM `cleanup_site_list_2011` WHERE county='kings') as X,
What kinds of considerations are there for migrating an application from NHibernate 1.2 to
Using an idea from Bob King idea I wrote the following method. It works
I'm beginning to understand how the forall keyword is used in so-called "existential types"
I am trying to integrate pages from a site I am building into the
I have a dataset that I'm trying to chunk up into "events" based on
I am using the PDO Database Abstraction library to make sure my code is
I'm using Matplotlib to plot a histogram. Using tips from my previous question: Matplotlib
Implementing Kings' Corners (glorified multiplayer Solitaire) in Java. I'm trying to allow a player
I am trying to make a template class where there is a function that

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.