1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change the color of numbers in output

Discussion in 'C' started by kabirk007, Dec 4, 2008.

  1. kabirk007

    kabirk007 New Member

    Joined:
    Dec 2, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hi everybody,

    i have a very simple question, plz. find the answer for me.

    we have designed a program which will show the numbers of 1-100.
    those numbers which are division of 2 show in red color.
    which are not division of 2 show in blue color.

    Thanks
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    So what have you tried with this because it does not seem to be a very difficult logic.
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Do you already know how to display text in red or blue?
    Do you know how to determine whether or not a number is divisible by 2?

    What operating system are you using, and what compiler? Display of coloured text is not standard in C and is platform and compiler specific.
     
  4. back from retirement

    back from retirement New Member

    Joined:
    Nov 9, 2008
    Messages:
    72
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Student, UG 1st Yr., Jadavpur University
    Location:
    Uttarpara, West Bengal, India
    Yes....in my Borland Turbo C++, display in colour is not possible...otherwise, the logic to use is very simple...you have to seperate the nos. from 1 to 100 in two arrays of equal size....depending on the odd-even criteria....and then use your logic to print one array in red, and the other in blue....as per instruction...
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Storing the numbers in two arrays seems unnecessarily complicated; the OP just says you have to display the numbers in red or blue which you can do without any storage (except a loop variable).
     
  6. back from retirement

    back from retirement New Member

    Joined:
    Nov 9, 2008
    Messages:
    72
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Student, UG 1st Yr., Jadavpur University
    Location:
    Uttarpara, West Bengal, India
    Yes....that's true....I haven't noticed it....
     

Share This Page