Thread: Help!!!!

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    18

    Exclamation Help!!!!

    I'm not asking anyone to do my homework but I am desperate to get help. I need a huge boost in the right direction. My program is to calculate the value of an expression involving arithmetic operators. The expression should be evaluated based on operator precedence. The program should prompt the user to input the expression and should indicate the end of the expression by inputting a character E. The expression should have only numeric values and operators to add, subtract, multiply, and divide.

    -The program should prompt the user to input only integer values
    -the program should be written for integer values in the expression
    -Arrays should be used to store the input values of the user
    -Output of the program should be an integer value
    -Functions can be used if necessary
    here is an example that a user might enter
    34
    *
    2
    +
    9
    -
    3
    E (terminates the program and then should print the answer)

    the program should display the correct answer and the numbers stored as integers and the operators stored as char. Please someone help me out anyway you can. here is what i have so far:
    #include <stdio.h>

    #define INTEGERS 500
    #define CHARACTERS 500

    int main()

    {
    int array1[ INTEGERS ];
    int i;
    int array2[ CHARACTERS ];
    char d;

    printf("Enter problem:\n");

    for(i=0; i<INTEGERS; i++)
    scanf("%d", &array1[i]);

    for(d=0; d<CHARACTERS; d++)
    scanf("%s", array2[d]);

    return 0;
    }

    i think i need to use a switch structure to do the operations but i have no clue on how to start it. im beggin you people, please help me out. thank you.

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Code:
    for(i=0; i<INTEGERS; i++) 
    scanf("%d", &array1[i]);
    This is insanity. You get the input with fgets. Than you disect it with sscanf.
    Last edited by Troll_King; 10-14-2001 at 12:43 PM.

Popular pages Recent additions subscribe to a feed