I need some help with a program which makes calculations that I'm suppose to write

Discussion in 'C Programming' started by takachi, Jan 1, 2008.

  1. takachi

    takachi

    Joined:
    Dec 26, 2007
    Messages:
    7
    Likes Received:
    0
    I need to write a function in C language which recieves an input as a string using the function gets.the input shuold consist of numbers (double) and the following actions:+,-.^,*,/ and brackets.The program should calculate the expression. the maximum length of the exspresion should be 195 chars.the program should calculate the expresion in the brackets at first, than the ^ and afterwards the / and * and at last the + and -.We assume that when we use the action ^ the second operand is an integer.
    In addition, I can use only the libary <stdio.h> and the libary <string.h> and only the basic functions,arrays,loops and conditions.


    Therefore, I need some help as soon as possible. my idea was to get the input as a string which I defined as char and than divided it into 2 strings, one was double and contained the numbers and the second was char and contained the operators and brackets. however, in order to be able to know the order of the numbers and operators I wanted to use one index for both new strings. this is where my biggest problem begins because the places which don't contain anything are considered as nulls,therefore,I can't scan the strings in order to find the brackets or anything else because in some stage I will get to one of those "nulls".

    I need some new ideas or a way to fix it.
    it's realy important and I would be glad if you answer me quickly.
     
    takachi, Jan 1, 2008
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.