Skip to content

Instantly share code, notes, and snippets.

@seyDoggy
Created April 10, 2013 23:14
Show Gist options
  • Save seyDoggy/5359273 to your computer and use it in GitHub Desktop.
Save seyDoggy/5359273 to your computer and use it in GitHub Desktop.
PSPC Final Exam
Problem Solving and Programming Concepts
Adam Merrifield (2697795).
Final Exam
################################
start
GetResponse()
stop
num prompt(string msg)
Declarations
num userNumber
output msg
input userNumber
return userNumber
num integerPower(num valueA, num valueB)
Declarations
num base = valueA
num exp = valueB
while(exp > 1)
base = base * base
exp = exp - 1
endwhile
return base
GetResponse()
Declarations
num QUIT = 0
string messageA = "Please enter the base value (" QUIT " to quit) --> "
string messageB = "Please enter the exponent value (" QUIT " to quit) --> "
num base = prompt(messageA)
num exp = prompt(messageB)
while (base != QUIT && exp != QUIT)
result = integerPower(base, exp)
output base " to the power of " exp " is " result
base = prompt(messageA)
exp = prompt(messageB)
endwhile
return void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment