Question: The above text file contains incomplete source code of a C# program which is supposed to accept any numbers of integers entered at the command

The above text file contains incomplete source code of a C# program which is supposed to accept any numbers of integers entered at the command line and display their sum. For example, assuming sum.cs is saved in C:\CNT4104Lab\ and, when it is completed, the screen below shows the use of 'cd', 'dir', and 'csc' commands, and the execution with output of this program with three integers, 100, 99, and -33. It can actually accept more input numbers, if you want.

using System;

class CNT4704Lab

{

public static void Main(string[] myInput)

{

int i, sum = 0;

Console.WriteLine(" You entered " + myInput.Length + " numbers:");

//

// Problem (1) Fix next line to complete the header of making a for loop......

//

for ()

{

Console.Write(myInput[i] + " ");

sum = sum + Int32.Parse(myInput[i]);

}

//

// Problem (2) Fix next line so the actual sum is displayed......

//

Console.WriteLine(" Sum of your input numbers = ");

Console.WriteLine(" Good Bye!");

}

}

Because two lines in the above given sum.cs are not completed, it cannot be compiled and executed. There is a line you must complete for a for-loop to work, and another line to fix so it displays the sum on screen.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!