C Problem 1 Fix next line to complete the header of making

C# ----->

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

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

{   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!\");   

}

}

Solution

{   public static void Main(string[] myInput)   

{      

int i, sum = 0;      

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

//      

// Solution(1) initialize i to 0 increment it by 1 upto length of array.....      

//      

for (int i=0;i<myInput.Length;i=i+1)      

{

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

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

//      

// Solution (2) - just write {0} for first parameter and include variable sum

//      

Console.WriteLine(\"\ \ Sum of your input numbers ={0} \",sum);      

Console.WriteLine(\"\ Good Bye!\");   

}

}

C# -----> Problem (1) Fix next line to complete the header of making a for loop...... Problem (2) Fix next line so the actual sum is displayed...... { public
C# -----> Problem (1) Fix next line to complete the header of making a for loop...... Problem (2) Fix next line so the actual sum is displayed...... { public

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site