How to print division in linux?

This is a discussion on How to print division in linux? within the C++ Programming forums, part of the General Programming Boards category; Uhm if anyone saw my previous question, then they would have a better idea of what am i asking here, ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    14

    How to print division in linux?

    Uhm if anyone saw my previous question, then they would have a better idea of what am i asking here, but i think it should be fine.. i can't seem to print out or cout a hit/miss on the screen, n though i have view the man printf but i still have no idea how to implement it...
    so how can i print something like for
    int hit, miss;

    printf(The hit/miss ratio is:",hit/miss)?? this won't work...
    can anyone please help me here?

  2. #2
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    Well, for one, you're missing the starting " but maybe that's just a typo here.
    What exactly is the output you get?
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    59
    printf(The hit/miss ratio is:",hit/miss)?? this won't work...
    Was that your actual code? In that case you forgot %d

    Code:
    printf("The hit/miss ratio is: %d",hit/miss)
    Last edited by erikj; 12-28-2003 at 05:57 AM.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    This might also be a rounding problem.
    Code:
    printf("The hit/miss ratio is: %f",((float)hit)/miss);
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 12:03 PM
  2. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  3. Linux for Windows!
    By Strut in forum Linux Programming
    Replies: 2
    Last Post: 12-25-2002, 11:36 AM
  4. Linux? Windows Xp?
    By VooDoo in forum Linux Programming
    Replies: 15
    Last Post: 07-31-2002, 09:18 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21