Answer:
See Explanation
Explanation:
Required
- Pseudocode to determine the largest of 10 numbers
- C# program to determine the largest of 10 numbers
The pseudocode and program makes use of a 1 dimensional array to accept input for the 10 numbers;
The largest of the 10 numbers is then saved in variable Largest and printed afterwards.
Pseudocode (Number lines are used for indentation to illustrate the program flow)
1. Start:
2. Declare Number as 1 dimensional array of 10 integers
3. Initialize: counter = 0
4. Do:
4.1 Display “Enter Number ”+(counter + 1)
4.2 Accept input for Number[counter]
4.3 While counter < 10
5. Initialize: Largest = Number[0]
6. Loop: i = 0 to 10
6.1 if Largest < Number[i] Then
6.2 Largest = Number[i]
6.3 End Loop:
7. Display “The largest input is “+Largest
8. Stop
C# Program (Console)
Comments are used for explanatory purpose
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] Number = new int[10]; // Declare array of 10 elements
//Accept Input
int counter = 0;
while(counter<10)
{
Console.WriteLine("Enter Number " + (counter + 1)+": ");
string var = Console.ReadLine();
Number[counter] = Convert.ToInt32(var);
counter++;
}
//Initialize largest to first element of the array
int Largest = Number[0];
//Determine Largest
for(int i=0;i<10;i++)
{
if(Largest < Number[i])
{
Largest = Number[i];
}
}
//Print Largest
Console.WriteLine("The largest input is "+ Largest);
Console.ReadLine();
}
}
}