I Am Down With Viral And Need Help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marsguy85
    New Member
    • Oct 2006
    • 27

    I Am Down With Viral And Need Help.

    hey ppl i am down with viral and have to submit assesment on this friday .
    i am new at c programming and have to write a program in it .
    ------------------------------------------------
    A program that repeatedly request an integer from the user and displays the integer as a binary number. It should terminate when the value 9999 is entered. A typical run might look like:
    Enter integer: 16
    000000000000000 000000000000100 00
    Enter integer: -1
    111111111111111 111111111111111 11

    --------------------------------------------------------------------------------------------------------
    PLEASE HELP ME COZ IF I DONT SUMBIT IT THAN I WILL LOSE MARKS AND I AM IN NO CONDITION TO DO IT AS I AM ON ANTIBIOTICS AND DONT HAVE STRENGTH .
    i know there are many experts here in ANSI C , and wont take a sweat for u guys to do it , please help me , will appreciate your help very very much.
    thanks
  • D_C
    Contributor
    • Jun 2006
    • 293

    #2
    You don't have the strength to do it? I don't think so...

    I'll still give you C++ code though that prints an integer as binary.
    Code:
    void printBinary(int input)
    {
      for(int i = 31; i >= 0; i--)
        cout << ((input && (1 << i)) >> i);
      cout << endl;
    }
    I haven't tested it, but it seems simple enough.

    Comment

    • marsguy85
      New Member
      • Oct 2006
      • 27

      #3
      Ansi C ............... .
      Not C++
      And I Swear I Am Down Wid Viral And Taking Antibiotics ! So Sleeping All Day Like Shit .
      Thanks Anyway But Its In Ansi C Not C++ Forgot To Mention It Sorry.

      Comment

      Working...