Sponsored Content
Full Discussion: calculator program..
Top Forums Shell Programming and Scripting calculator program.. Post 302099872 by sahithi_khushi on Thursday 14th of December 2006 10:59:32 AM
Old 12-14-2006
calculator program..

Hey can anyone tell me the korn script code to implement an interactive integer calculator using the shell's built in arithemetic expression evaluation
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculator

I am pretty new to the Unix word, and have created a working calculator script. I have one problem. It doesn't use any decimals, it rounds off to the nearest whole number. 1 #!/bin/ksh 2 while true; do 3 echo -n "Enter the first integer: "; read IN1 4 test... (2 Replies)
Discussion started by: ironhead3fan
2 Replies

2. UNIX for Dummies Questions & Answers

calculator

hi, im new to the unix system and scripting and was wondering if anyone could help me with this problem iv been havin... i want the system to: 1. ask me for a number 2. ask me for a command to use on that number (* + - /) 3. ask me for another number 4. then ask me for another command, if the... (2 Replies)
Discussion started by: jdougy
2 Replies

3. Shell Programming and Scripting

Bash Calculator issue

Hello, I'm relatively new to using bc so I could use some help. In this script im working on I want to have the bc function to calculate float numbers for imagemagicks convert charcoal. Below is what I'm talking about. There are no syntax errors but when it outputs the users frames for example 0-10... (2 Replies)
Discussion started by: jsells20
2 Replies

4. Shell Programming and Scripting

Help with calculator code

Hi Guys, I found this code in net.. it is working fine.. But can anybody explain me the sed statement used in the code.. echo "Enter the expression:\c" read express eval echo "$express"|sed 's/^/'$precision' \ /'|bc -l|\ sed -n '1,${ /syntax/!{ } ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

5. Shell Programming and Scripting

Permission bit calculator ???

Hi, Does anyone have a UNIX permission bit calculator script that I can use? Basically, am looking for one where I don't have to a ls -l to check the permission on a file or directory. Am looking for a script that will display the permission bits and then just display what those permission... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. Homework & Coursework Questions

Simple Calculator

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known/data: Script a simple calculator. In the command line enter the script file /home/etc/mycalc or /home/etc/mycalc 1 +... (6 Replies)
Discussion started by: herb bertz
6 Replies

7. Shell Programming and Scripting

Can't get my program to run -- GC calculator?

have been trying for a few weeks not to get this program running. I am newer to programming and it has definitely been a challenge. I think my problem arises with my if statement. I can get it to append the name to the new file, but it simply appends the whole sequence to the file rather than... (3 Replies)
Discussion started by: haley6719
3 Replies
ICALC(1)						      General Commands Manual							  ICALC(1)

NAME
       icalc - interactive calculator

SYNOPSIS
       icalc [ file ]

DESCRIPTION
       Icalc  is  a algebraic calculator designed primarily for interactive use.  Each formula definition file is read and compiled.  The standard
       input is then read, expressions are evaluated and results are sent to the standard output.  If a newline  is  escaped  using  a	backslash,
       input is continued on the next line.

       An expression contains real numbers, variable names, function calls, and the following operators:

	    +  -  *  /	^

       Operators  are  evaluated left to right, except '^', which is right associative.  Exponentiation has the highest precedence; multiplication
       and division are evaluated before addition and subtraction.  Expressions can be grouped with parentheses.  Each result is assigned  a  num-
       ber,  which  can  be  used in future expressions.  For example, the expression ($3*10) is the result of the third calculation multiplied by
       ten.  A dollar sign by itself may be used for the previous result.  All values are double precision real.

       In addition, variables and functions can be defined by the user.  A variable definition has the form:

	    var = expression ;

       Any instance of the variable in an expression will be replaced with its definition.  A function definition has the form:

	    func(a1, a2, ..) = expression ;

       The expression can contain instances of the function arguments as well as other variables and functions.  Function names can be	passed	as
       arguments.  Recursive functions can be defined using calls to the defined function or other functions calling the defined function.

       To  define a constant expression, simply replace the equals sign ('=') with a colon (':') in a definition.  Constant expressions are evalu-
       ated only once, the first time they are used.  This avoids repeated evaluation of expressions whose values never change.  Ideally,  a  con-
       stant  expression contains only numbers and references to previously defined constant expressions and functions.  Constant function defini-
       tions are are replaced by their value in any expression that uses them with constant arguments.	All  predefined  functions  and  variables
       have  the  constant attribute.  Thus, "sin(PI/4)" in an expression would be immediately replaced by ".707108" unless sin() or PI were rede-
       fined by the user.  (Note that redefining constant expressions is not a recommended practice!)

       A variable or function's definition can be displayed with the '?'  command:

	    ? name

       If no name is given, all definitions are printed.  The '>' command writes definitions to a file:

	    > file

       Similarly, the '<' command loads definitions.

       The following library of predefined functions and variables is provided:

       PI	 the ratio of a circle's circumference to its diameter.

       if(cond, then, else)
		 if cond is greater than zero, then is evaluated, otherwise else is evaluated.	This function is necessary for	recursive  defini-
		 tions.

       select(N, a1, a2, ..)
		 return  aN (N is rounded to the nearest integer).  This function provides array capabilities.	If N is zero, the number of avail-
		 able arguments is returned.

       rand(x)	 compute a random number between 0 and 1 based on x.

       floor(x)  return largest integer not greater than x.

       ceil(x)	 return smallest integer not less than x.

       sqrt(x)	 return square root of x.

       exp(x)	 compute e to the power of x (e approx = 2.718281828).

       log(x)	 compute the logarithm of x to the base e.

       log10(x)  compute the logarithm of x to the base 10.

       sin(x), cos(x), tan(x)
		 trigonometric functions.

       asin(x), acos(x), atan(x)
		 inverse trigonometric functions.

       atan2(y, x)
		 inverse tangent of y/x (range -pi to pi).

AUTHOR
       Greg Ward

SEE ALSO
       ev(1), rcalc(1), tabfunc(1)

RADIANCE							      2/3/95								  ICALC(1)
All times are GMT -4. The time now is 03:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy