Programming Exercises

   


1:

Write the pseudocode for an algorithm that determines the maximum number of two given numbers. Hint: Use the following logic: If number1 is greater than number2, number1 is the maximum number; otherwise, number2 is greater than or equal to number1.

2:

Write the pseudocode for an algorithm that determines the maximum number in a given list of numbers. The list can contain any amount of numbers. Hint: Keep a variable called maxSoFar (written on the paper, with zero as the initial value). Go through the list one by one and compare each number with maxSoFar. Any number found to be greater than maxSoFar becomes equal to maxSoFar. At the end of the list, maxSoFar represents the largest number in the list.

3:

Change the average-calculating pseudocode in the section "Algorithms and Pseudocode" so that it doesn't perform division by zero, even when no numbers are provided.

4:

Write, compile, and run a C# program that writes the following on the console:

 Our alien friend lives on planet Blipos far far away 


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net