Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

What's wrong with my programme??

  • 17-04-2012 03:36PM
    #1
    Banned (with Prison Access) Posts: 67 ✭✭


    forget about the calculations, the top part of the program is fine and working well, I just want the the computer to return a value for e that it calcualtes:

    Cheers

    #include<stdio.h>
    main()
    {
    int(a);
    printf("how many drinks have you consumed");
    scanf("%lf",&a);
    int(b);
    printf("what was the volume of these beverages");
    scanf("%lf",&b);
    int(c);
    printf("what was the percentage of these beverages");
    scanf("%lf",&c);
    int(d);
    d==a*b*c*0.01;
    scanf("%lf",&d);
    int(e);
    e==((d/5000)*100);
    scanf("%lf",&e);
    printf("%lf",&e);
    system("pause");
    return(0);
    }


Comments

  • Registered Users, Registered Users 2 Posts: 2,814 ✭✭✭Gone Drinking


    An app to work out if you're over the limit..

    HELLO DRAGONS DEN!!1

    :pac:


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    It's a while since I've done C programming, but those declarations look different to what I used to use... was more like

    int a;

    from what I remember.. What error are you getting.


  • Registered Users, Registered Users 2 Posts: 774 ✭✭✭maki


    Your syntax is a bit wonky. You only need to have one equals in the places where you have two.


  • Registered Users, Registered Users 2 Posts: 6,265 ✭✭✭MiCr0


    this looks a lot like homework


  • Banned (with Prison Access) Posts: 67 ✭✭bananarama22


    MiCr0 wrote: »
    this looks a lot like homework
    seriosuly isn't, I'm a chem student, just trying C programming for the craic

    ok, I got rid of the double = and replaced it with a single.

    Not getting particular error message, cmd comes upp and the messages, like how much have you drunk, volume, percentage etc, when I type in the last parameter, the cmd just stays blank


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 774 ✭✭✭maki


    seriosuly isn't, I'm a chem student, just trying C programming for the craic

    ok, I got rid of the double = and replaced it with a single.

    Not getting particular error message, cmd comes upp and the messages, like how much have you drunk, volume, percentage etc, when I type in the last parameter, the cmd just stays blank

    That's because the program is waiting on you to input something for the variables d and e.
    Get rid of the scanf lines for d and e, and delete the ampersand in the final printf.

    Also, system("pause") probably won't work unless you #include <stdlib.h>
    You should probably use floats instead of integers since you're doing so much dividing. Scanf is expecting a float each time anyway since you're using &lf


  • Banned (with Prison Access) Posts: 67 ✭✭bananarama22


    maki wrote: »
    That's because the program is waiting on you to input something for the variables d and e.
    Get rid of the scanf lines for d and e, and delete the ampersand in the final printf.

    Also, system("pause") probably won't work unless you #include <stdlib.h>
    You should probably use floats instead of integers since you're doing so much dividing. Scanf is expecting a float each time anyway since you're using &lf


    Cheers bud, Works like a charm now :D

    this isn't part of your proffession by any chance is it??


  • Moderators, Technology & Internet Moderators Posts: 11,017 Mod ✭✭✭✭yoyo




  • Closed Accounts Posts: 2,207 ✭✭✭longhalloween


    I'm not exactly sure what you're trying to calculate but here's my attempt to make it work.
    #include <stdio.h>

    main(){

    int a;
    float b,c,d,e;

    printf("how many drinks have you consumed\n");
    scanf("%d",&a);

    printf("what was the volume of these beverages\n");
    scanf("%f",&b);

    printf("what was the percentage of these beverages\n");
    scanf("%f",&c);

    d = a*b*c*0.01;
    e =(d/5000)*100;

    printf("%f\n",e);
    system("pause");
    return(0);
    }


  • Banned (with Prison Access) Posts: 67 ✭✭bananarama22


    Thanks everyone, I got it working :D How do I close this thead now ?? :confused:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,182 ✭✭✭Genghiz Cohen


    Thanks everyone, I got it working :D How do I close this thead now ?? :confused:
    return;
    


  • Closed Accounts Posts: 326 ✭✭whitesands


    OP's question answered so I have to ask.
    An app to work out if you're over the limit..

    HELLO DRAGONS DEN!!1

    :pac:
    Seriously??? Someone went on Dragons Den with a similar app :confused::p


Advertisement