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

Username:   Password: 
 RegisterRegister   
 Can someone please explain to me how to use words in 'for' statements?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JLChow




PostPosted: Tue Nov 03, 2015 5:08 pm   Post subject: Can someone please explain to me how to use words in 'for' statements?

What is it you are trying to achieve?
Trying to understand how to use words in loops and repetition in general. These questions below ere given tome to practice but I don't understand how to complete them. I have tried various methods but something is always wrong.


What is the problem you are having?
These are the questions/problems that were given to me:

Write a program that reads words entered one to a line and

counts how many words have been entered before you give

the signal word "end" to stop execution of the program.

Experiment to determine what happens if you put several

words on a line as you enter them.


and

A series of marks is to be entered and averaged.

Before you enter the series you are to have the program ask you how

many marks there are in the series then read it in. Test your

program to see that it works for series of different lengths, say

four marks or six marks.


and finally the big one...

6.aWrite a program to output a table of values of the integers

starting at 1 and their squares. Label the table at the top of the

columns. For example, your output might look like this

Number Square

1 1

2 4

3 9

4 16

5 25

Try to format the output so that it looks attractive. What

happens as the numbers get larger and larger? Change the

122 Introduction to Programming in Turing


[i]6.b Modify your program so that in one for loop you output the

Num Square Num Square Num Square Num

1 1 21 441 41 1681 61 3721

2 4 22 484 42 1764 62 3864

program to output the first 100 integers rather than attempting

to go on forever.

following

Square

continue through to

20 400 40 1600 60 3600 80 6400



Describe what you have tried to solve this problem
Tried using various methods which I have not saved...but everytime it would fail.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
N/A Will try to provide ASAP.

Turing:


<Add your code here>



Please specify what version of Turing you are using
<4.1.1>
Canada Canada Canada Canada Canada
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Nov 03, 2015 6:07 pm   Post subject: RE:Can someone please explain to me how to use words in \'for\' statements?

You should give an example of what you've tried and how it went wrong, to set context on what direction you are heading in, and what kind of problems should be solved. This makes the difference between "you should try this other command" and "you have the right approach, but use this command differently".
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  [ 2 Posts ]
Jump to:   


Style:  
Search: