Helping converting pseudocode into c++

Reversing the order using arrays

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 1780 Views - Last Post: 16 November 2009 - 05:09 AM Rate Topic: -----

#1 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Helping converting pseudocode into c++

Posted 14 November 2009 - 08:17 PM

I have to allow th user to enter 10 values, and then reverse the order..
ex(1, 2, 3, 4, 5) and it's supposed to look like (5, 4, 3, 2, 1)..
I wrote it in pseudocode.. I'm just not good w/ c++.


Start

Num input

Num MAX_COUNT = 10

Num ARRAY_LIMIT = MAX_COUNT -1

COUNT [MAX_COUNT] =

1, 2, 3, 4, 5,

6, 7, 8, 9, 10

Get input

For input = 0 to ARRAY_LIMIT

count > 0

Print COUNT [input]

Count = count -1

Endfor

Stop



This code has to be written in c++, not C.

Is This A Good Question/Topic? 0
  • +

Replies To: Helping converting pseudocode into c++

#2 janotte   User is offline

  • code > sword
  • member icon

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

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:25 PM

Write some code.

Post it here (between code tags) and we can help you make it better.

We can't write the code for you.
Was This Post Helpful? 0
  • +
  • -

#3 induz   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 13-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:29 PM

you have to define a array of 10 elements

int size = 10
array[size]



//now the loop

for ( int x = 0; x<size; x++)
{
//now ask the user

cout<<"Enter 10 numbers";

cin >> array[x]

}



i dont know how to reverse the number in this array

** Edit ** :code:

This post has been edited by no2pencil: 14 November 2009 - 08:35 PM

Was This Post Helpful? 0
  • +
  • -

#4 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:31 PM

View Postjanotte, on 14 Nov, 2009 - 07:25 PM, said:

Write some code.

Post it here (between code tags) and we can help you make it better.

We can't write the code for you.


#include<iostream>
using namespace std;

int main()
{
int input;
cout << "Enter number : ";
cin >> input;
for(int i = 1; i <= input; i++)
{
cout << i << " ";
}
ret



** Edit ** :code:
Was This Post Helpful? 0
  • +
  • -

#5 janotte   User is offline

  • code > sword
  • member icon

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

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:35 PM

Remember you need to wrap your code in code tags
See posting rule 4

See what happens when you do that and you use some indenting:
#include<iostream>
using namespace std;

int main()
{
   int input;
   cout << "Enter number : ";
   cin >> input;
   for(int i = 1; i <= input; i++)
   {
	  cout << i << " ";
   }
ret



Now you need to do some work on the rest of your code.
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:35 PM

Any chance we can start using code tags :)

Also, ret isn't a function.
Was This Post Helpful? 0
  • +
  • -

#7 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:37 PM

Yeah, I didn't copy it right.. Soory..

#include<iostream>
using namespace std;

int main()
{
int input;
cout << "Enter number : ";
cin >> input;
for(int i = 1; i <= input; i++)
{
cout << i << " ";
}
return 0;
}



** Edit ** :code:
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:38 PM

View Postkoolmoecee, on 14 Nov, 2009 - 09:37 PM, said:

Yeah, I didn't copy it right.. Soory..

...& you still didn't use code tags.

:code:
Was This Post Helpful? 0
  • +
  • -

#9 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:44 PM

View Postno2pencil, on 14 Nov, 2009 - 07:38 PM, said:

View Postkoolmoecee, on 14 Nov, 2009 - 09:37 PM, said:

Yeah, I didn't copy it right.. Soory..

...& you still didn't use code tags.

:code:



Sorry, I'm new here.
Was This Post Helpful? 0
  • +
  • -

#10 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:46 PM

I understand, but I've had to edit every post in this topic. It's one thing to not know, but when you see the posts changing & it was pointed out to you by both myself & janotte. It's not the worst thing ever, I understand, but please use them when posting code.

Thank you.
Was This Post Helpful? 0
  • +
  • -

#11 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:49 PM

K, is anyone gonna help me or whatttt?
Was This Post Helpful? 0
  • +
  • -

#12 janotte   User is offline

  • code > sword
  • member icon

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

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 08:57 PM

View Postkoolmoecee, on 14 Nov, 2009 - 07:49 PM, said:

K, is anyone gonna help me or whatttt?


You need to store the inputs.
What are you going to store them in?
Maybe an array?
Declare an array and store your inputs in there as the next step in your program.
Was This Post Helpful? 0
  • +
  • -

#13 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 09:03 PM

View Postjanotte, on 14 Nov, 2009 - 07:57 PM, said:

View Postkoolmoecee, on 14 Nov, 2009 - 07:49 PM, said:

K, is anyone gonna help me or whatttt?


You need to store the inputs.
What are you going to store them in?
Maybe an array?
Declare an array and store your inputs in there as the next step in your program.



I'm totally lost..
:(
Was This Post Helpful? 0
  • +
  • -

#14 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 09:04 PM

View Postkoolmoecee, on 14 Nov, 2009 - 09:49 PM, said:

K, is anyone gonna help me or whatttt?


I think you are confusing "asking for help" with "asking for someone to do it", because I see a bunch of posts where help has been offered.

Have a look through the Tutorials & Snippets.

Here is a perfect example of code to reverse an array. Except it uses chars instead of integers.
Was This Post Helpful? 0
  • +
  • -

#15 koolmoecee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-November 09

Re: Helping converting pseudocode into c++

Posted 14 November 2009 - 09:10 PM

View Postno2pencil, on 14 Nov, 2009 - 08:04 PM, said:

View Postkoolmoecee, on 14 Nov, 2009 - 09:49 PM, said:

K, is anyone gonna help me or whatttt?


I think you are confusing "asking for help" with "asking for someone to do it", because I see a bunch of posts where help has been offered.

Have a look through the Tutorials & Snippets.

Here is a perfect example of code to reverse an array. Except it uses chars instead of integers.



That's not the style of c++ we use in class. And I clearly stated above I wasn't good w/ c++.
I just want to know how am I supposed to define the array and where.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3