Answer to Question #26640 in C++ for shahid

Question #26640
What is an algorithm? Write an algorithm to read five integers and find out if the values are in ascending order.
1
Expert's answer
2013-03-29T07:20:18-0400
In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning. More precisely, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, will proceed through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

An algorithm to read five integers and find out if the values are in ascending order:

for i=0, i<5, i=i+1:
read a[i];

for i=1, i<5, i=i+1:
if a[i-1]>=a[i]
{
print "the values are not in ascending order";
exit;
}

print "the values are in ascending order";
exit;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS