Sponsored Content
Homework and Emergencies Homework & Coursework Questions Sum of even numbers from 0 to 100 script Post 303031732 by wisecracker on Tuesday 5th of March 2019 03:08:29 AM
Old 03-05-2019
Hi Nastybutler...

Take a look at my pseudocode, post #5 again.
Your code; there are numerous minor errors and to go through them all before you have solved your project would mean I would be writing it.
Let's get your logic sorted first. You will see from my CODE section how different you logic is from mine.

These lines are fine:
(Just a note, there is no need for the double brackets [[ ]] for this example, single brackets [ ] would suffice. It will still work with double brackets however.)
Code:
#!/bin/bash

counter=0
sum=0

while [[ $counter -le 100 ]]
do
        Important line. "do your arithmetic here which uses both SUM and COUNT"
        Unimportant OPTIONAL print. This can be omitted.
        Important line. "increase your COUNTer by your NEEDED amount"
done
IMPORTANT "print your final value here and should equal the last line of you optional listing"

Again read Don's post #4 thoroughly...

Have another go, and if you increase your "counter" by a certain even number then you will see it all fall into place.
And finally, please use CODE tags, the "</>" icon on the tool bar.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to sum numbers in column

Hi, i want to sum all nubers in one column. Example: 12.23 11 23.01 3544.01 I'm trying to do this in awk, but it doesn't work properly. Seems like awk is summing only integers, for example: 12 11 23 3544 It cuts off numbers after dot. I used this command: akw /text/ file.txt |nawk... (1 Reply)
Discussion started by: iahveh
1 Replies

2. Shell Programming and Scripting

sum numbers from stdout

hello im looking for short way to sum numbers from stdout the way i found to do it is to long for me i wander if there is shorter way to do it ok it 2 stage action this will make the list of number in to file sum.txt grep -c include *.c | awk '{l=split($0,a,":");print a;}' > sum.txt this... (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Shell script to find the sum of first n Fibonacci numbers

pls give me the solution for this i need it for my exam pls pls pls Shell script to find the sum of first n Fibonacci numbers (1 Reply)
Discussion started by: Kshitija
1 Replies

4. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

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: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

5. Shell Programming and Scripting

Finding the sum of two numbers

cat *.out |grep "<some text>" | awk '{print $6}' For ex,This will reutrn me 11111 22222 is it possible to add these two numbers in the above given command itself?I can write this to a file and find the sum. But I prefer to this calculation in the above given line itself. Any... (3 Replies)
Discussion started by: prasperl
3 Replies

6. Shell Programming and Scripting

getting the sum of numbers

I basically have a file where I had to do a bunch of greps to get a list of numbers example: a file called numbers.txt 10000 10000 superman 10000 batman 10000 10000 grep '100' * | 10000 10000 10000 10000 10000 (2 Replies)
Discussion started by: zerofire123
2 Replies

7. Shell Programming and Scripting

Sum Numbers from different files

Hi All, I need to print the sum of numbers from different files. Input files: file1.out 10 20 30 file2.out 10 20 30 (5 Replies)
Discussion started by: saint2006
5 Replies

8. Shell Programming and Scripting

Script Shell: Count The sum of numbers in a file

Hi all; Here is my file: V1.3=4 V1.4=5 V1.1=3 V1.2=6 V1.3=6 Please, can you help me to write a script shell that counts the sum of values in my file (4+5+3+6+6) ? Thank you so much for help. Kind regards. (3 Replies)
Discussion started by: chercheur111
3 Replies

9. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies

10. UNIX for Beginners Questions & Answers

Sum even numbers from 1 to 100

I need help with this assignment. I'm very new to using UNIX/LINUX, and my only previous experience with programing anything is using python. We are writing scripts using vim, and this one I'm stumped on. "Write a shell script that finds and display the sum of even positive integers from 0 to... (5 Replies)
Discussion started by: Nastybutler
5 Replies
MARIA-CSO(1)						      General Commands Manual						      MARIA-CSO(1)

NAME
maria-cso - shared library generator for maria SYNOPSIS
maria-cso directory library.so file.c... maria-cso directory library.so file.c DESCRIPTION
This manual page documents briefly the maria-cso command. maria-cso is a shell script invoked by maria in order to compile generated C code into dynamically loadable shared object files. The script invokes the C compiler and the linker, and it calculates checksums in order to avoid compiling unmodified modules. The directory argument specifies the location of the source files. When the script is invoked with one file.c argument, it translates the file to the shared object library.so. When maria-cso is invoked with multiple file.c arguments, it computes a checksum of a file named multiset.h and of each argument. When the header file multiset.h has been changed since the previous invocation of maria-cso, everything will be recompiled. Otherwise only those file.c modules that have been modified will be recompiled. The checksum files are multiset.sum and c.sum. SEE ALSO
maria(1), sh(1). ENVIRONMENT VARIABLES
CC Name of the C compiler CFLAGS Command-line switches to be passed to the C compiler DEFINES Preprocessor macro definitions to be passed to the C compiler FILES
/usr/share/maria/runtime/*.h Header files for the run-time library AUTHOR
This manual page was written by Marko Makela <msmakela@tcs.hut.fi>. The maria-cso script and the compilation option were designed and implemented by Marko Makela. Please see the copyright file in /usr/share/doc/maria for details. August 10, 2001 MARIA-CSO(1)
All times are GMT -4. The time now is 05:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy