pls help!!!

This is a discussion on pls help!!! within the C Programming forums, part of the General Programming Boards category; in my homework i wrote a fuction that calculates some prices and prints to screen: int one,two,sum; one+=4.45; two+=3.56; printf("%d",one); ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    pls help!!!

    in my homework i wrote a fuction that calculates some prices and prints to screen:

    int one,two,sum;

    one+=4.45;
    two+=3.56;

    printf("%d",one);
    printf("%"itwo);

    and the output is like that:

    4
    3
    doesnt
    4.45
    3.56
    i used float but this time the output is
    0
    0
    how can i fix this problem???

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    This should work:
    printf ( "%.2f\n", one );
    printf ( "%.2f\n", two );

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 07:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 02:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 09:46 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 07:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM

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