Answered by:
C# Adding integers, averages of numbers and the difference of these numbers
Question

My instructor has a program he wanted me to create and I am having difficulties..I am new to this and trying to understand. I am having problems with the sum, average, product and the difference on how to write the code exactly
Enter a number...4Total numbers inputted so far = 1Enter another number...50Total numbers inputted so far =2Enter another number...51Total numbers inputted so far =3Enter final number...3     Total Numbers Entered is 4     The Sum of the numbers is...108The Difference of the Numbers is...100The Average of the Numbers is...27The Product of the numbers is...30600The result of Special Case 1 is...2562The result of Special Case 2 is...54    Are these numbers less than 50?    Number 1 = YESNumber 2 =NONumber 3 = NONumber 4 =YES(Here are the calculations of the special case 1 and special case 2....1. Find the products of numbers 2 and 3 and numbers 1 and 4and add them together in that order.a. This all needs to be done in the code2. Find the products of numbers 2 and 4 and numbers 1 and 3and subtract them in that order.a. This all needs to be done in the codeIf the average has a decimal, it must show the text to display theremainder. If there is no decimal, then the remainder text does notneed to show.Don’t forget about the Console.Readline() at the end or else youIn my book...in chapter 3 It says..Another C# APP: Adding IntegersDisplaying the sum of two numbers input from the keyboardin the ex , in the console window it writesint number1; // declare the first number to addint number2; // declare the second number to addint sum; declare the sum of number1 and number2then..Console. Write( " Enter first integer: "); // prompt user//read first number from usernumber1 = Convert.ToInt32( Console.ReadLine() );Console.Write( "Enter second integer; "); //prompt user//read second number from usernumber2 = Convert.ToInt32_Console.Readline() ); sum = number1 + number2; //add numbersConsole.WriteLine( "Sume is {0}" , sum); //display the sumI am really confused exactly how to do the difference and the average...since example of sum in book think i can do that but the difference and average etc...would it be on one line........ difference = 450513;Console.Write( "The Difference of the numbers is...{0}" , difference); ????
Answers

I am really confused exactly how to do the difference and the average...since example of sum in book think i can do that but the difference and average etc...would it be on one line........ difference = 450513;Console.Write( "The Difference of the numbers is...{0}" , difference); ????
Once you know the sum, the average is just the sum / the number of items.
The difference can be done on one line, but you can also split it up:
int difference = firstItem; for (int i=1;i<numberOfItems;++i) // Skip first item here difference = difference  item[i];
 Proposed as answer by Damon Bu  MSFT Tuesday, September 10, 2013 3:37 AM
 Marked as answer by Damon Bu  MSFT Thursday, September 12, 2013 7:59 AM