Pseudo code

I need help with a previous assignment

Page 1 of 1

11 Replies - 4784 Views - Last Post: 25 November 2008 - 01:05 PM Rate Topic: -----

#1 clb8372   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-November 08

Pseudo code

Post icon  Posted 23 November 2008 - 05:22 PM

Can someone please help me with understanding how a pseudo code is suppose to look. I thought I understood the instructor but  am seeming to get more and more confused. My instructor had given me feedback but i have know clue as to what he is implying. Can someone please take a look at the attachment and view his feed back and let me know how to complete a pseudo code. 

Thank you so much

Attached File(s)


Is This A Good Question/Topic? 0
  • +

Replies To: Pseudo code

#2 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Pseudo code

Posted 23 November 2008 - 11:57 PM

Welcome!

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 lanec42   User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 229
  • Joined: 26-March 08

Re: Pseudo code

Posted 24 November 2008 - 12:45 AM

pseudo+code = fake(pseudo) + code(code)

So pseudocode is fake code, i.e. English that is structured like code.


Example:

Question: Write pseudocode for adding two numbers.

Answer:

1. prompt user for the first number
2. store it as "a"
3. prompt user for the second number
4. store it as "b"
5. c = a + b
6. display c

(At least that's what I would consider pseudocode... be sure that you understand exactly what your instructor wants.)

Edit: lol, I kept typing "sudo code". I guess there can be too much Linux.

This post has been edited by lanec42: 24 November 2008 - 12:46 AM

Was This Post Helpful? 0
  • +
  • -

#4 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Pseudo code

Posted 24 November 2008 - 01:43 AM

A few things:

1 - You should only be wrapping code in [co de] ... [/co de]. Your text doesn't belong inside those tags.

2 - Attachments are a real pain. Better to cut the relevant text out so we don't have download stuff etc. Just makes it a bit harder than it needs to be for people to help you.

On to your main questions:

Instructor Feedback A -
The flowcharts are another issue. You only attempted to complete the MAIN flowchart and what you have does not match what you have in your pseudo code. I am not sure what information from my pseudo code I should have entered into my flow chart.

5 out of 35 points



Comment A -
You didn't provide your flowcharts so I'm " not sure what information from [your] pseudo code [you] should have entered into my flow chart." either.

Instructor Feedback B -
In you MAIN module you call a WELCOME MESSAGE module but you don't have one
defined in the code. I don’t understand how to fix this.


Comment B -
To fix this you need to define a welcome message module in your pseudo code.

Instructor Feedback C -
Why do you have a variable named ItemName? Variable names should be descriptive
 of what the are being used for. What do you mean by this?

In your INPUT module you first ask for the items name but not for the name of
 the currency you want to convert. You then ask for the currency type but input
 the currency amount. I am not sure what was wrong with this part of the program. 



Comment C -
The instructor is wondering why you write “Enter the item’s name?”.
What do you expect the user to enter here?
What are you going to do with that information?

Then your ask the user to enter a currency name immediately followed by "Input currency dollar amount".
Where did you get the amount from?
You never asked the user to give it to you so how can you input it?
What are you doing with the currency name you asked for?
You never seem to use that for anything.



Instructor Feedback D -
Your PERFORM CALCULATIONS module does not perform any calculations. You do set
 the sourcerate variable to different rates (but only for 4 of the specified
 currencies) You never perform the currency conversion. I have had trouble with this area. Do you have an example on how to do this?

15 out of 35 points



Comment D -
The hint is here "You never perform the currency conversion."
You need to set out how to convert from one currency to another in you pseudo code.
Perhaps:
SET newCurrency EQUAL TO oldCurrency MULTIPLIED BY exchangeRate
Depending on what pseudo code conventions your instructor has asked you to follow.

-------
I am now going to say some things which are genuine questions and suggestions.
They are neither rhetorical nor intended to be rude.

Can I ask if English is your first language?
If it isn't then you may have difficulty in your studies without some supplementary English language skills.
You may need to ask your educational institution if there is some assistance with English language available to you.

If English is your first language then you are going to need to pause and think carefully if IT is the right area for you to be studying.
If you are committed to the IT path then perhaps you need to investigate if there are options for you to get some extra help and/or tutoring.
If the fairly direct feedback you are getting from your instructor isn't making sense then you have to realise it is going to get a lot harder very quickly as you progress along and if this is really not making sense to you then the later stuff will be even worse.
There's no shame in admitting we aren't good at some things and focusing on things we are good at.
Was This Post Helpful? 0
  • +
  • -

#5 clb8372   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-November 08

Re: Pseudo code

Posted 24 November 2008 - 11:59 AM

View Postjanotte, on 24 Nov, 2008 - 12:43 AM, said:

A few things:

1 - You should only be wrapping code in [co de] ... [/co de]. Your text doesn't belong inside those tags.

2 - Attachments are a real pain. Better to cut the relevant text out so we don't have download stuff etc. Just makes it a bit harder than it needs to be for people to help you.

On to your main questions:

Instructor Feedback A -
The flowcharts are another issue. You only attempted to complete the MAIN flowchart and what you have does not match what you have in your pseudo code. I am not sure what information from my pseudo code I should have entered into my flow chart.

5 out of 35 points



Comment A -
You didn't provide your flowcharts so I'm " not sure what information from [your] pseudo code [you] should have entered into my flow chart." either.

Instructor Feedback B -
In you MAIN module you call a WELCOME MESSAGE module but you don't have one
defined in the code. I don’t understand how to fix this.


Comment B -
To fix this you need to define a welcome message module in your pseudo code.

Instructor Feedback C -
Why do you have a variable named ItemName? Variable names should be descriptive
 of what the are being used for. What do you mean by this?

In your INPUT module you first ask for the items name but not for the name of
 the currency you want to convert. You then ask for the currency type but input
 the currency amount. I am not sure what was wrong with this part of the program. 



Comment C -
The instructor is wondering why you write “Enter the item’s name?”.
What do you expect the user to enter here?
What are you going to do with that information?

Then your ask the user to enter a currency name immediately followed by "Input currency dollar amount".
Where did you get the amount from?
You never asked the user to give it to you so how can you input it?
What are you doing with the currency name you asked for?
You never seem to use that for anything.



Instructor Feedback D -
Your PERFORM CALCULATIONS module does not perform any calculations. You do set
 the sourcerate variable to different rates (but only for 4 of the specified
 currencies) You never perform the currency conversion. I have had trouble with this area. Do you have an example on how to do this?

15 out of 35 points



Comment D -
The hint is here "You never perform the currency conversion."
You need to set out how to convert from one currency to another in you pseudo code.
Perhaps:
SET newCurrency EQUAL TO oldCurrency MULTIPLIED BY exchangeRate
Depending on what pseudo code conventions your instructor has asked you to follow.

-------
I am now going to say some things which are genuine questions and suggestions.
They are neither rhetorical nor intended to be rude.

Can I ask if English is your first language?
If it isn't then you may have difficulty in your studies without some supplementary English language skills.
You may need to ask your educational institution if there is some assistance with English language available to you.

If English is your first language then you are going to need to pause and think carefully if IT is the right area for you to be studying.
If you are committed to the IT path then perhaps you need to investigate if there are options for you to get some extra help and/or tutoring.
If the fairly direct feedback you are getting from your instructor isn't making sense then you have to realise it is going to get a lot harder very quickly as you progress along and if this is really not making sense to you then the later stuff will be even worse.
There's no shame in admitting we aren't good at some things and focusing on things we are good at.


Thanks for your feedback. I did want to say that this class is the only class I have left to complete before I graduate, but my field of study is web design. I am not sure why this class was even given to me. I have no experience in computer programming and if I had the choice, I would not have chosen this class because I do not understand the language. My main issue is trying to understand what is required of me to complete my assignments. The material provided for this class is way over my head, so I am stuck with just completing the assignments to the best of my knowledge. Once again thanks for your response....it was very helpful.
Was This Post Helpful? 0
  • +
  • -

#6 clb8372   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-November 08

Re: Pseudo code

Posted 24 November 2008 - 12:07 PM

View Postn8wxs, on 23 Nov, 2008 - 10:57 PM, said:

Welcome!

[rules][/rules]



HI I am sorry, I do not understand. You stated that I should post something in the
 
area but then I was was advised something different from a previous post from Janotte. I'm not sure i understand what goes between the
 
area.


Thanks
Was This Post Helpful? 0
  • +
  • -

#7 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Pseudo code

Posted 24 November 2008 - 01:26 PM

View Postclb8372, on 24 Nov, 2008 - 11:07 AM, said:

View Postn8wxs, on 23 Nov, 2008 - 10:57 PM, said:

Welcome!

[rules][/rules]



HI I am sorry, I do not understand. You stated that I should post something in the
 
area but then I was was advised something different from a previous post from Janotte. I'm not sure i understand what goes between the
 
area.


Thanks



This is text.
"How much wood can a woodchuck chuck?"
It goes outside the [co de] ... [/co de] tags

This is code.
while(woodchucked != MAXWOOD) {
	cout << "Wood chucked so far is " << woodchucked << " and the woodchuck is still chucking wood." << endl;
	woodchucked++;
}


It goes inside the [co de] ... [/co de] tags

This post has been edited by janotte: 24 November 2008 - 01:26 PM

Was This Post Helpful? 0
  • +
  • -

#8 Osamah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-November 08

Re: Pseudo code

Posted 24 November 2008 - 04:49 PM

hello everyone..i have been trying to translate a pseudocode into Borland C++ and having too much trouble since am a beginner.
the pseudocode is:

1) define an array of integers P. set all elements Pi to 0 for 2<=i<=n.
2) set i to 2.
3)if i>n the algorithm terminates.
4)if Pi is zero then i is prime. // this is where i cant understand.
5)for all positive integers of j, such that ixj<n, set Pi*j to 1.// what is the j for?
6) add 1 to i and go to step 3.
this is what i wrote using loops and arrays. i please need your feedback on this:)

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#define n 500
main(){

int P[n];
int i;
int j;


for(i>=2;i<=n;++i){

P[i]=0;

}

i=2;
while(i<n){

if(P[i]==0){

P[i]=i;
}

for(j=0;i*j<n;++j){

P[i*j]=1;
++i;
}
}
cout<<P[i*j]<<endl;
getch();
return 0;

}
Was This Post Helpful? 0
  • +
  • -

#9 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Pseudo code

Posted 24 November 2008 - 10:25 PM

Did you read the multiple posts above about following posting rule 3 and posting code between the [co de] ... [/co de] tags?
Please follow that advice in future as it makes it easier for us to help you.

Your code is a strange mish-mash of C and C++. You would do better to make the decision to code in either C or in C++ and stick to it until you master (at least somewhat) one language before working on another. My strong recommendation is to use strict C++ to learn on. It's just nicer in a few ways that make things easier for a beginner than C.

My comments will assume you are going to use C++

1 - #includes <____.h> are usually C. Please use the C++ versions. (e.g. iostream.h is C, the C++ equivalent is <iostream AND in C++ use <cstdio> not <stdio.h>.

2 - in C++ main() always returns an int so should be written "int main()"

3 - This "for(i>=2;i<=n;++i){" is not a valid for-loop declaration.

That's as far as I got before I got bored.
Was This Post Helpful? 0
  • +
  • -

#10 Osamah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-November 08

Re: Pseudo code

Posted 25 November 2008 - 08:06 AM

well thats what i have been taught in class, i frankly do not knw the difference between C and C++. i just have to take this course and its hard. thats all i can tell you.

why is the "for loop" not a valid declaration?
Was This Post Helpful? 0
  • +
  • -

#11 Osamah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-November 08

Re: Pseudo code

Posted 25 November 2008 - 08:13 AM

the code am supposed to write is to show the prime numbers up to 500 using the sieve of eratothenes. i dont see how this functions from the seudocode. any help?
Was This Post Helpful? 0
  • +
  • -

#12 PostulateMan   User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 14-September 08

Re: Pseudo code

Posted 25 November 2008 - 01:05 PM

The for loop is not valid because it does not follow the format:

for (initialize; conditional; iteration)

You can check if i is greater than or equal to 2 and less than or equal to n, but not in that format. Now, because you're trying to detect prime numbers I think you wanted to initialize i to 2. Remember that a semi-colon separates each part of the for loop.

This post has been edited by PostulateMan: 25 November 2008 - 01:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1