using System; using System.Collections.Generic; using System.Text; namespace ExerciseOne { class Program { static void Main(string[] args) { int grade = 0; int smallest = 0; int counter; bool result; for (counter = 1; counter <= 5; counter++) { do { Console.Write("\nPlease enter the number: "); result = int.TryParse(Console.ReadLine(), out grade); if (!result) Console.Write("\nPlease enter number only."); } while (!result); if (grade > smallest) smallest = grade; } Console.Write("\nsmallest: {0}", grade); Console.ReadLine(); } } }

Well...This is the basic a very basic program that finds the smallest number and display the average. I am always having a hard time finding the smallest number. Would you guys please, if possible show me a better way to find the smallest number? Though, the program display the correct output and the calculation is correct, but the way I wrote the code is not logical. Instead of assigning the smallest number to the smallest variable, I use grade, which is not a proper way. If you don't understand, you can take a look at my program, and you know what I am talking about.

if (grade > smallest) smallest = grade; } Console.Write("\nsmallest: {0}", grade); Console.ReadLine();

This is incorrect.