10-01-2012
How do you write this program/script?
I need help with the following.
1) Write a program in any language that takes a single integer array parameter and returns the decimal average of the input values.
2) Write a program, in any language, that prints the integers from 1 to 10, along with a cumulative sum of the integers printed so far. Your program's output should look like
this:
1 1
2 3
3 6
4 10
5 15
6 21
7 28
8 36
9 45
10 55
9 More Discussions You Might Find Interesting
1. Programming
i want to write a server process in the sco unix 505.The server process will fork multi-child-processes when it first starts.once parent process listen and accept any connect from client,it will transfer the connected sockfd to any free child process and child process will read client request from... (4 Replies)
Discussion started by: hit
4 Replies
2. Shell Programming and Scripting
i need the a c program that simulates the "ls" command:b: (5 Replies)
Discussion started by: madhu.it
5 Replies
3. Shell Programming and Scripting
Hi,
I am having an input file which contains a group of words,if one specific word comes which goes to next line.
example:
input file===>
shashi country= india comapny= none shashi shashi company= NONE shashi=my name
output===>
shashi country= india comapny= none
shashi
shashi... (6 Replies)
Discussion started by: hegdeshashi
6 Replies
4. UNIX for Dummies Questions & Answers
I have to
Write a program in C that recognizes the following commands and translates them into much simpler ones
Commands to recognize shorter command
list L
cd dir C - dir_length - dir
get file_name G - file_name_length - file_name
Long commands are read from the standard input and... (1 Reply)
Discussion started by: aintour
1 Replies
5. Homework & Coursework Questions
I have to
Write a program in C that recognizes the following commands and translates them into much simpler ones
Commands to recognize shorter command
list
L
cd dir
C - dir_length - dir
get file_name G - file_name_length - file_name
Long commands are read from the standard input... (1 Reply)
Discussion started by: aintour
1 Replies
6. Shell Programming and Scripting
Output file template format
<input_file_name>a</input_file_name>
<total_length_size>b</total_length_size>
<log_10_length_size>c</log_10_length_size>
Input_file_1 (eg. sample.txt)
SDFSDGDGSFGRTREREYWW
Parameter:
a is equal to the input file name
b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies
7. Shell Programming and Scripting
Hello..
I want to take back up from server to local machine and i dont know how to do it using cron and sftp . I can do it by manually typing password in the terminal and taking the back up. How to create a 'backup.sh' file for doing all the back up process and shut down automatically after... (1 Reply)
Discussion started by: deepoos
1 Replies
8. Shell Programming and Scripting
Hi,
Here is my question:
I want a shell script which I name as 'del', and can be used as del(string).
when run del(string), it will delete several directories at different locations in my system,like:
rm -fr /lustre/fs/scratch/user/$string
rm -fr /home/user/$string
rm -fr... (4 Replies)
Discussion started by: 1988PF
4 Replies
9. UNIX for Dummies Questions & Answers
I am hoping someone can give me a good free web resource for writing code to compile a binary executable. I am getting fairly decent at writing shell script, are the .f files just shell scripts? Also, I don't know where to begin on the makefiles. The reason I am curious is because I have been... (6 Replies)
Discussion started by: butson
6 Replies
BC(1) General Commands Manual BC(1)
NAME
bc - arbitrary-precision arithmetic language
SYNOPSIS
bc [ -c ] [ -l ] [ file ... ]
DESCRIPTION
Bc is an interactive processor for a language which resembles C but provides unlimited precision arithmetic. It takes input from any files
given, then reads the standard input. The -l argument stands for the name of an arbitrary precision math library. The syntax for bc pro-
grams is as follows; L means letter a-z, E means expression, S means statement.
Comments
are enclosed in /* and */.
Names
simple variables: L
array elements: L [ E ]
The words `ibase', `obase', and `scale'
Other operands
arbitrarily long numbers with optional sign and decimal point.
( E )
sqrt ( E )
length ( E ) number of significant decimal digits
scale ( E ) number of digits right of decimal point
L ( E , ... , E )
Operators
+ - * / % ^ (% is remainder; ^ is power)
++ -- (prefix and postfix; apply to names)
== <= >= != < >
= += -= *= /= %= ^=
Statements
E
{ S ; ... ; S }
if ( E ) S
while ( E ) S
for ( E ; E ; E ) S
null statement
break
quit
Function definitions
define L ( L ,..., L ) {
auto L, ... , L
S; ... S
return ( E )
}
Functions in -l math library
s(x) sine
c(x) cosine
e(x) exponential
l(x) log
a(x) arctangent
j(n,x) Bessel function
All function arguments are passed by value.
The value of a statement that is an expression is printed unless the main operator is an assignment. Either semicolons or newlines may
separate statements. Assignment to scale influences the number of digits to be retained on arithmetic operations in the manner of dc(1).
Assignments to ibase or obase set the input and output number radix respectively.
The same letter may be used as an array, a function, and a simple variable simultaneously. All variables are global to the program.
`Auto' variables are pushed down during function calls. When using arrays as function arguments or defining them as automatic variables
empty square brackets must follow the array name.
For example
scale = 20
define e(x){
auto a, b, c, i, s
a = 1
b = 1
s = 1
for(i=1; 1==1; i++){
a = a*x
b = b*i
c = a/b
if(c == 0) return(s)
s = s+c
}
}
defines a function to compute an approximate value of the exponential function and
for(i=1; i<=10; i++) e(i)
prints approximate values of the exponential function of the first ten integers.
Bc is actually a preprocessor for dc(1), which it invokes automatically, unless the -c (compile only) option is present. In this case the
dc input is sent to the standard output instead.
FILES
/usr/share/misc/lib.b mathematical library
dc(1) desk calculator proper
SEE ALSO
dc(1)
L. L. Cherry and R. Morris, BC - An arbitrary precision desk-calculator language
BUGS
No &&, ||, or ! operators.
For statement must have all three E's.
Quit is interpreted when read, not when executed.
7th Edition October 21, 1996 BC(1)