Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Help
Author Message
Thanos

Posted: Mon Sep 09, 2002 8:46 pm   Post subject: Help

Hey guys, I need some help with this thing im working on. It's the beginning of school so don't worry, this is not a school project. I'm just trying to get ahead in class. Anyway, my question is what is the code for averaging a bunch of numbers? what's the code for sum?
I'm trying to create a program that will average some school marks.

Dan

Posted: Tue Sep 10, 2002 10:47 am   Post subject: help

ok here is a progame that will avg any number of numbers:

 code: var numofnums : int var curentnum : int var total : int := 0 put "how many nus to avg?" get numofnums for i : 1 .. numofnums     put "plz put in number ", i     get curentnum     total += curentnum end for put "the avg of thess nums is: ", total div numofnums

now i dont know how much you know about turing so here are some of the basciks:

 code: var a:int %decare 1st var var b:int %decare 2nd var var total:int a := 2 %set a to 2 b := 2 %set b to 2 total:= a+b %add a with b and store the value in total put total %print the aswer on the screen

avg is done like in math by adding the numbers up then diveding by the amout of nums.

if you need any more help or anything fell free to post any time.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony

Posted: Tue Sep 10, 2002 4:51 pm   Post subject: grr

Dan, its the beginning of school and the guy is asking you how to add numbers? You just give him some code with for loops and no documentary... Could have used arrays as well

Well just keep in mind that you got to remember at what knowledge level people are.

As for Thanos, good luck with your programming Dan will be posting some 'insparational' source code up on the board cuz I'LL BE DOING VB instead.

Oh, Dan, nice quote you got there... BTW, I'm fine now
Tony's programming blog. DWITE - a programming contest.
Dan

Posted: Tue Sep 10, 2002 7:30 pm   Post subject: sory

ok, may be i shode have made it more basick.

ok here is some math stuff in turing:

- subtractes two numbers

:= asings a value to a var

+= adds a number to a var

-= subtraces a number from a var

div diveds a number by another

* mutiplyes a number by another

puting it togther:

lets say we whont to disay an awers to 5 + 5 on the screen, we coude do this:

 code: put 5 + 5

to add two vars together and put it on the screen you coude do this:

 code: var a:int:=5 var b:int:=5 put a + b

to add two vars together and soter that number in a var:

 code: var a:int:=5 var b:int:=5 var c:int c:= a + b

all this can be done the same using +, -, *, /, and div

so to do a simpe version of the avg thing you can do this:

 code: var n1:int:= 100 var n2:int:= 10 var n3:int:= 50 var avg:int avg:= (n1 + n2 + n3) div 3 put avg

p.s. is that ok with you tony, lol
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Thanos

Posted: Fri Sep 13, 2002 5:06 pm   Post subject: (No subject)

Hey guys, thanks for all the help.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: