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

Posted: Tue Dec 10, 2002 9:28 am   Post subject: help

write a program to count the total number of characters in a series of 10
words that you enter, and compute the average word lenght.

Tony

Posted: Tue Dec 10, 2002 12:14 pm   Post subject: (No subject)

use length(text:string) to get the length of the string. Then add them all up and divide by total number of words.
Tony's programming blog. DWITE - a programming contest.
mac

Posted: Tue Dec 10, 2002 1:28 pm   Post subject: what

what is the code bro
Tony

Posted: Tue Dec 10, 2002 4:44 pm   Post subject: (No subject)

come on man, learn to read outside the code box.

 code: length(text)

where text is the word. and this function outputs the lenght of it.

so

 code: var text:string := "tony" var l:int l := length(text) put l

This will output 4 since word "tony" is 4 characters long.

Understand now?
Tony's programming blog. DWITE - a programming contest.
Dan

Posted: Tue Dec 10, 2002 5:31 pm   Post subject: la la la

or you can do it the realy cheep way with getch

ie.

 code: var num:int:=0 var key:string(1) loop         getch(key)         num += 1 end loop

well you will have to put in some if's to stop it.

i dont know why i posted this becuse tony's way is a lot better, oh well
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony

Posted: Tue Dec 10, 2002 6:00 pm   Post subject: (No subject)

I think dan is doing some gargabe posts just to make himself look better

lol

though if you're to use getch() then it to exit it should be something like this:

 code: loop getch(l) if l="Q" then exit else num:=num+1 end if end loop

though this way you can't use capital Q in any of your words...
Tony's programming blog. DWITE - a programming contest.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

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