What problems exist within the following code? C# Explain each problem, and indi
ID: 642563 • Letter: W
Question
What problems exist within the following code? C#
Explain each problem, and indicate whether it is a syntax error or a logic error.
C# Programing Language
long N; string X; double B; long M; long Q = 4; long R = 3;
N = Console.WriteLine();
// Countdown 5 to 3
or (int I = 5; (I <= 3); I--) { if ((I > 3)) X = 6; else X = 45.3;
}
N = 45 / M;
while (Q > R) { Q++;90 }
// Add 1 to Q and then multiply it by 2
Q = 1 + (Q * 2);
Console.ReadLine();
What problems exist within the following code? C# Explain each problem, and indicate whether it is a syntax error or a logic error. C# Programing Language long N; string X; double B; long M; long Q = 4; long R = 3; N = Console.WriteLine(); // Countdown 5 to 3 or (int I = 5; (I 3)) X = 6; else X = 45.3; } N = 45 / M; while (Q > R) { Q++;90 } // Add 1 to Q and then multiply it by 2 Q = 1 + (Q * 2); Console.ReadLine();Explanation / Answer
Error in N = Console.WriteLine(); change it to N = Console.ReadLine(); because you want to read in a number to N
This is syntax error
Error in X = 6. change it to X = "6"; because X is a string variable
Error in X = 45.3. change it to X = "45.3"; because X is a string variable
Error in N = 45 / M; M is not initialized
Error in Q = 1 + (Q * 2) change it to Q = (1 + Q) * 2;
all the errors are syntactical except for the last one
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.