I need help writing in IPO Chart and pseudocode for an assignment asking to "Write a program that prompts the user to input a positive integer. He should then output a message indicating whether the number is a prime number."
This is what I came up with for the IPO chart:

I P O
Positive integer Get user input Positive integer
Message (i,e. Prime number) Message
Positive integer Find the result based on integer entered Result
Positive integer, message, Result Display all Positive integer, message, Result

We don't do your homework for you. Try first and we can critique your efforts. Quick PS for this, to get you started.
1. Get input number.
2. If < 0 emit error and exit
3. If >= 0 see if is prime number.
4. If prime, huzza!
5. Else emit error and exit.

Rubberman,

Note that I was NOT asking anybody to DO my homework for me. If you take the time to read my post thoroughly, you will notice that I showed what I had come up with thus far. It's just that I wasn't sure if I did was correct and needed somebody's constructive feedback.

I understood that, but your PS was so ambivalent that it is effectively useless. That is why I posted a sample for you. The purpose of pseudo-code is to express clearly what is to be done. That should be easily morphed into real code, depending upon the language you are going to program it in. After 30+ years of serious software development, I still use pseudo-code to help me clarify my intentions and designs. It helps tremendously to eliminate logic errors for the most part.

FWIW, I meant PC (pseudo-code) instead of PS in previous posts... Danged keyboard keeps mis-typing... :-)

Edited 3 Years Ago by rubberman

This article has been dead for over six months. Start a new discussion instead.