Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why wont it add up? What am I doing wrong?

    #include<stdio.h>
    #include <stdlib.h>

    int main (void)
    {
    //local declarations

    int h,b,r;

    //get inputs

    //Statments
    printf("Enter h\n");
    scanf("%lf",&h);
    printf("Enterb\n");
    scanf("%lf",&b);




    r = h + b;
    printf("The total hours studied is:%.3lf\n\n",&r);

    printf("Yep.\n");

    system("pause");
    return 0;
    } //main


    Okay this is like an example of the code I wrote, everything seems to be working fine but my numbers wont add up. It just says 0.000. I've tried everything but I dont know how to fix it. What am I doing wrong? Am I missing a code?

  • #2
    New Coder
    Join Date
    Jul 2013
    Posts
    48
    Thanks
    0
    Thanked 2 Times in 2 Posts
    codes seems absolutely fine but i think may be its not running because of a missing space in enterb

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I figured out what it was. Apparently it needed to be in float.

  • #4
    New Coder
    Join Date
    Jul 2013
    Posts
    48
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by BeginerCodes View Post
    I figured out what it was. Apparently it needed to be in float.
    yes....silly me....should have picked that out


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •