Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 example problem??? I'm totally lost!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cutiegirl_14_16




PostPosted: Thu Mar 06, 2003 8:25 pm   Post subject: example problem??? I'm totally lost!

ok so here's the program
assuming that the variables are already declared

loop
put "Enter a number. To end the program type stop"
exit when number=-999
count:=count+1
end loop
put "The number of number's entered is", count


How do u change the program to read the series of numbers and determine the total sum of the numbers entered.

help would be great!!!!!!!
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Mar 06, 2003 8:30 pm   Post subject: (No subject)

same thing, but instead of counting how many number were entered (+1 through each run) you add up the total (current total + number entered)

so

code:
loop
put "Enter a number. To end the program enter -1"
get number
exit when number=-1
total := total + number
end loop

put "the total is: ", total


it should be -1 instead of "stop" because that way you'd have to get input as string and convert it to integer with strint() and its extra work... so just -1 or 0 or w/e other number you dont think user would use.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
cutiegirl_14_16




PostPosted: Thu Mar 06, 2003 8:35 pm   Post subject: (No subject)

thanx...ur a life saver....twice!
Tony




PostPosted: Thu Mar 06, 2003 8:36 pm   Post subject: (No subject)

Very Happy no problem, thats what this site is for Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: