Thread: New to C Programming and Need Help

  1. #1
    Registered User
    Join Date
    Oct 2007

    New to C Programming and Need Help

    Hey guys/gals,

    I am new to programming and have a class assignment. I am trying to make these functions within functions work right. They compile just fine, but when I run the program it does not work. I do not need someone to completely do my problem for me, but if you could suggest on one of my functions what I am doing wrong I will change the others. I have looked all over google trying to figure this out. Here is my source code please let me know what I need to change.



    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #define minhour 60 /*Minutesd in an Hour*/
    #define ltoml 1000 /*Liters to Milliliters*/
    int main(void)
        float rateml = 0, ratemg = 0, rateunit = 0, hour = 0, dropfactor = 0, patient = 0,
        conml = 0, conunit = 0;       /* The options */
        int menu;                     /* Menu Options */
        float total1, total2, total3, total4; /* The totals */
    while(menu !=5)
    int get_problem();
    switch (menu)                  /* select the type of option */
        case 1:void get_rate_drop_factor();
        case 2: void get_liter_per_hour();
        case 3: void get_kg_rate_conc();
        case 4: void get_units_conc();
        default: printf("\n***Invalid option selected***\n");
    if (menu == 1)    
        printf("The drop rate per minute is %.0f\n", total1);    
    else if (menu == 2)
        printf("The rate in milliliters per hour is %.0f\n", total2);    
    else if (menu == 3)
        printf("The rate in milliliters per hour is %.0f\n", total3);
    else if (menu == 4)
        printf("The rate in milliliters per hour is %.0f\n", total4);            
    return (0);
    /* Main Menu */
    int get_problem();
    int get_problem(int menu)
        printf("\n\nIntravenous Rate Assistant\n");
        printf("\n\nWhat would you like to do?\n\n");    /* WRITE instructions */
        printf("\t1 = ml/hr & Tubing Drop Factor\n");
        printf("\t2 = 1 L for n Hour\n");
        printf("\t3 = mg/kg/hr & Concentration in mg/ml\n");
        printf("\t4 = units/hr & Concentration in units/ml\n");
        printf("\t5 = QUIT\n");
        printf("\n\nEnter the problem you wish to solve:");
        scanf("%d",&menu);                   /* Read menu option */
    /* Case 1 */
    void get_rate_drop_factor(float);
    void get_rate_drop_factor(float rateml, float dropfactor, float total1)
         printf("Enter rate in ml/hr:");
             scanf("%f", &rateml);
             printf("Enter tubing's drop factor (drops/ml):");
             scanf("%f", &dropfactor);
             total1 = ((dropfactor * rateml) / minhour);
    /* Case 2 */         
    void get_liter_per_hour(float);
    void get_liter_per_hour(float hour, float total2)
         printf("Enter number of hours:");
             scanf("%f", &hour);
             total2 = (ltoml / hour);
    /* Case 3 */        
    void get_kg_rate_conc(float); 
    void get_kg_rate_conc(float ratemg, float patient, float conml, float total3)
         printf("Enter rate in mg/kg/hr:");
             scanf("%f", &ratemg);
             printf("Enter patient weight in kg:");         
             scanf("%f", &patient);         
             printf("Enter concentration in mg/ml:");                  
             scanf("%f", &conml);         
             total3 = (ratemg * conml * patient);
    /* Case 4 */
    void get_units_conc(float);
    void get_units_conc(float rateunit, float conunit, float total4)
         printf("Enter rate in units/hr:");         
             scanf("%f", &rateunit);         
             printf("Enter concentration in units/ml:");                  
             scanf("%f", &conunit);                  
             total4 = (rateunit / conunit);

  2. #2
    Registered User
    Join Date
    Oct 2001
    what compiler are you using? you need to turn up your warning levels.

Popular pages Recent additions subscribe to a feed