Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

What's wrong with my programme??

  • 17-04-2012 2: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,811 ✭✭✭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: 772 ✭✭✭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: 772 ✭✭✭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