Giter Site home page Giter Site logo

expr-calc's Introduction

expr-calc

Simple program in C for evaluating arithmetic expressions.

Overview:

  1. operates on floating point numbers
  2. expressions are composed of infix operators, parantheses, multi-argument functions and constants
  3. each operation has a priority that defines operation precedence
  4. can work either in interactive mode in which it evaluates each expression on the input (separated by line break) or evaluate expression given in program arguments

Usage

  1. basic operations

All operations in expression have to be written explicitly (2(1+2) is wrong) and each label can mean only one operation (so there is no 'negation -', there is only 'subtraction -') 2. sequences

One can input a sequence of expressions separated by commas. Each of them will be evaluated and the result will be displayed. 3. functions

Functions can be called in two ways:

  • f(expr1, expr2)
  • f expr1 expr2

In the second case if the expressions contain any operators, they need to be wrapped in brackets as functions have higher priority than any operator.

Operators

  1. multiplying: "*"
  2. division: "/"
  3. addition: "+"
  4. subtraction: "-"
  5. exponentiation: "^"

Functions:

  1. square root: sqrt(expr)
  2. square: sqr(expr)
  3. factorial: fact(expr)
  4. exponentiation: pow(expr1, expr2)

expr-calc's People

Contributors

ilikeheaps avatar

Watchers

 avatar  avatar

expr-calc's Issues

sqrt, sqr don't work in some cases

To reproduce:
compile with gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 under Xubuntu 14.04 LTS with -std=c99
run, input sqrt(4)
desired output: 2, program output: 4
input 1+sqrt(4)
desired output: 3, program output: 3
input sqr(10)
desired output: 100, program output: 10
input sqr(10)+1
desired output: 101, program output: 101

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.