|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Pseudocode to count integers
Hi
I need some help. Does anyone know the pseudocode to count integers in a file? Thanks in advance! ![]() |
|
#2
|
||||
|
||||
|
a little bit vague! How about giving us the file?
did u mean. How to count the number of values in a file e.g. 10 lines with 10 values or something else?
__________________
To fly a Kite high you have to fly against the wind! think about it..... deep man deep!! Current Project Contact me |
|
#3
|
||||
|
||||
|
let me guess, it's a homework assignment?
--Simon
__________________
|
|
#4
|
|||
|
|||
|
It is the number of integers that are in the file not the values. It could be thought of as homework.
Suzie |
|
#5
|
||||
|
||||
|
so what have you tried?
|
|
#6
|
||||
|
||||
|
yeah come on!
its homework for a reason!! at least give it a go b4 looking for the answer! otherwise ur not gonna learn! |
|
#7
|
|||
|
|||
|
Ok I have not used pseudocode before but here is my effort:
Begin procedure to count how many integers are in the file Add integers to array list If array = empty Then Msg box show “There is no data in the file” Statement is true End If If statement is false Then COUNT integers (variables) and loop until no more integers Store in the variable then output to text box End If End procedure |
|
#8
|
|||
|
|||
|
How far off the track am I?
|
|
#9
|
||||
|
||||
|
you've done ok!
from my experience of writing Pseudocode for Uni they usuaully expect a little bit more detail and evaluation of variables u used. For example you simply put : "COUNT integers and loop until no more integers" By the sounds of it this is the most important part of the Pseudo code and you have wrapped it up in one line. Personally i would break this down into a While loop e.g Pseudo code: int ll_count //counting variable boolean lb_continue = true while lb_continue = true (condition = true) // u use a while loop when u do not know how many variables you are reading in. Read variable in if exists = false (if there is a value) // you could change this to is it EOF lb_condition = false //exiting the while loop else isit a number // a bit of validation to make sure it is infact a number if yes ll_count add one end if end if loop thats roughly what i would do for that main part. But you still have to go into more detail baout locating the file and opeinging it. hope that helps! |
|
#10
|
|||
|
|||
|
Hi
This is really helpful thank you. I will work on it more today. Suzie ![]() |
|
#11
|
||||
|
||||
|
In the pseudocode we've used, the only form of loop available was like so
repeat ... until <condition> so you'd do something like this repeat read line from file 1 if line is an integer increment numberOfValues store line in array `values` end if until numberOfValues = 10
__________________
~James [Not currently seeking freelance work] Like philosophy or interested in spirituality? Philosophorum. Game Dev Experts Forums Foresight Linux - Because your desktop should be cool! Linux FAQ FedoraFAQ UbuntuGuide |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Pseudocode to count integers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|