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: Fri Jan 03, 2003 5:17 pm   Post subject: Help!

Hi everyone, im a beginner Turing Student and was wondering if you could help me with something. You can see what my problem is in the attatchment, thanks for taking ur time to read my msg. Here is my code (yea i know, it's crappy ) :

 code: var count, sum, sumSq, sumCu := 0 put "      Sum of the       Sum of the squares       Sum of the cubes" put "N   natural numbers      of the nautral          of the natural" put "      from 1 to N      numbers from 1 to N     numbers from 1 to N" put repeat ("_", 80) loop     count := count + 1     sum := sum + count     sumSq := sumSq + count ** 2     sumCu := sumCu + count ** 3     put count ..     put repeat (" ", 9), sum ..     put repeat (" ", 20), sumSq ..     put repeat (" ", 22), sumCu     exit when count = 10 end loop

turing problem.JPG
Description:
Filesize:  116.58 KB
Viewed:  4372 Time(s)

Izzy

Posted: Fri Jan 03, 2003 6:16 pm   Post subject: (No subject)

Heya.

 code: var count, sum, sumSq, sumCu := 0 put "      Sum of the       Sum of the squares       Sum of the cubes" put "N   natural numbers      of the nautral          of the natural" put "      from 1 to N      numbers from 1 to N     numbers from 1 to N" put repeat ("_", 80) loop     count := count + 1     sum := sum + count     sumSq := sumSq + count ** 2     sumCu := sumCu + count ** 3     put count:2 ..     put sum:10 ..     put sumSq:22 ..     put sumCu:24     exit when count = 10 end loop

Instead of putting the spaces in which will throw off the spacing when the digits increase (one digit, two and so on) use what i put, take a look at it, i'm sure you can figure out what it does

- Izzy
Tony

Posted: Fri Jan 03, 2003 6:47 pm   Post subject: (No subject)

hey Izzy, appretiate you helping people out keep it up

put text:10

that :10 means that text will be displayed in a 10 character space. If text is under 10 characters in length, more spaces will be added to display it as a 10 characters string.

Note that if text is more then 10 characters in length, it will still be displayed at full and alighment will be broken.

If user inputs are to be aligned, it might be a good idea to run a sort to find the largest word and align based on its length.
Tony's programming blog. DWITE - a programming contest.
Izzy

Posted: Fri Jan 03, 2003 6:59 pm   Post subject: (No subject)

Heya.

I figured I would tell you this aswell, just an expansion on the current subject, and you might need it

 code: var a : real := 11.116 put a:10:2

When you add a second : number on it formats the decimal place. So for are real number 11.116 it will hold the 10 spaces for the number then format the decimal place to two digits. Thus the output would be

11.12 (Don't hold me on the spacing )

- Izzy
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 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: