Find the error(s) in each of the following code segments and explain how to correct it: a)
Question:
Find the error(s) in each of the following code segments and explain how to correct it:
a) i = 1;
while (i <= 10);
++i;
}
b) for (k = 0.1; k != 1.0; k += 0.1)
{
Console.WriteLine(k);
}
c) switch (n)
{
case 1:
Console.WriteLine("The number is 1");
case 2:
Console.WriteLine("The number is 2");
break;
default:
Console.WriteLine("The number is not 1 or 2");
break;
}
d) The following code should display the values 1 to 10:
n = 1;
while (n < 10)
{
Console.WriteLine(n++);
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (12 reviews)
a Error The semicolon after the while header causes an infinite loop and ther...View the full answer
Answered By
Somshukla Chakraborty
I have a teaching experience of more than 4 years by now in diverse subjects like History,Geography,Political Science,Sociology,Business Enterprise,Economics,Environmental Management etc.I teach students from classes 9-12 and undergraduate students.I boards I handle are IB,IGCSE, state boards,ICSE, CBSE.I am passionate about teaching.Full satisfaction of the students is my main goal.
I have completed my graduation and master's in history from Jadavpur University Kolkata,India in 2012 and I have completed my B.Ed from the same University in 2013. I have taught in a reputed school of Kolkata (subjects-History,Geography,Civics,Political Science) from 2014-2016.I worked as a guest lecturer of history in a college of Kolkata for 2 years teaching students of 1st ,2nd and 3rd year. I taught Ancient and Modern Indian history there.I have taught in another school in Mohali,Punjab teaching students from classes 9-12.Presently I am working as an online tutor with concept tutors,Bangalore,India(Carve Niche Pvt.Ltd.) for the last 1year and also have been appointed as an online history tutor by Course Hero(California,U.S) and Vidyalai.com(Chennai,India).
4.00+
2+ Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Find and correct the error in each of the following code segments: a) const int ArraySize = 5; ArraySize = 10; b) Assume var b = new int[10]; for (var i = 0; i
-
Find the error(s) in each of the following code segments. Explain how to correct the error. a) void G() { Console.WriteLine("Inside method G"); void H() { Console.WriteLine("Inside method H"); } }...
-
Find and correct the error(s) in each of the following segments of code: a) For (i = 100, i >= 1, ++i) { Console.WriteLine(i); } b) The following code should display whether integer value is odd or...
-
find the steady state expression for vo in the circuit fig 9.32 if ig = 500cos2000tmA 3) 9.32 Find the steady-state expression for u,, in the circuit of Fig. P9.32 if i = 500 cos 2000 mA. Figure...
-
Indicate what a heuristic is and give four examples of it?
-
Adams Corporation accountants have assembled the following data for the year ended June 30, 2014: Prepare the operating activities section of Adams statement of cash flows for the year ended June 30,...
-
Explain the term makespan. LO.1
-
Refer to the information in Exercise 9-11. Assume that each of the company's divisions has a required rate of return of 7%. Compute residual income for each division. In Exercise 9-11 Kraft Foods...
-
SANDHILL INC. COMPARATIVE BALANCE SHEET AS OF DECEMBER 31, 2017 AND 2016 12/31/17 12/31/16 Cash $6,000 $7,100 Accounts receivable 61,400 51,500 Short-term debt investments (available-for-sale) 34,600...
-
Company Selection and Financial Retrieval: Pick a public company that piques your interest. Obtain its latest financial statements. 2. Cash Flow Interpretation: Using the acquired financial data,...
-
Write a C# statement or a set of C# statements to accomplish each of the following tasks: a) Sum the odd integers between 1 and 99, using a for statement. Assume that the integer variables sum and...
-
Describe the four basic elements of counter-controlled iteration.
-
How does the time consistency problem apply to the conduct of monetary policy? How might long terms of office for central bankers help overcome it?
-
Activity 1.4: When Less Becomes More For this activity, refer to the images shown. This is an activity which was performed for you if you do not have available two identical mirrors at home. But if...
-
! Required information [The following information applies to the questions displayed below.] Aces Incorporated, a manufacturer of tennis rackets, began operations this year. The company produced...
-
During the early part of winter, one morning, two hunters decided to go quail hunting on a property where the owner had given them permission to hunt. A nearby forest ranger saw the hunters and...
-
Required information [The following information applies to the questions displayed below.] Trini Company set the following standard costs per unit for its single product. Direct materials (30 pounds...
-
A horticulturist knows that the weights of honeybees that have previously visited her orchard are normally distributed with a mean of 0.87 grams, and a population standard deviation of 0.15 grams....
-
The integral of tan x can be derived using substitution and the fact that tan x = sin x/cos x. Determine whether each statement is true or false, and explain why.
-
ABC company leased new advanced computer equipment to STU Ltd on 1 January 2019.STULtd has to pay annual rental of $290,000 starting at 1 January 2019. It is a four years lease with ultimate rental...
-
Redo the justification of Proposition 7.2 assuming that the the cost of growing the array from size k to size 2k is 3k cyber-dollars. How much should each push operation be charged to make the...
-
The java.util.ArrayList includes a method, trimToSize( ), that replaces the underlying array with one whose capacity precisely equals the number of elements currently in the list. Implement such a...
-
Give a justification of the running times shown in Table 7.1 for the methods of an array list implemented with a (nonexpanding) array.
-
5. The current spot exchange rate is 0.95/$ and the three-month forward rate is 0.91/$. Based on your analysis of the exchange rate, you are pretty confident that the spot exchange rate will be...
-
Ray Company provided the following excerpts from its Production Department's flexible budget performance report. Required: Complete the Production Department's Flexible Budget Performance Report....
-
Problem 1 5 - 5 ( Algo ) Lessee; operating lease; advance payment; leasehold improvement [ L 0 1 5 - 4 ] On January 1 , 2 0 2 4 , Winn Heat Transfer leased office space under a three - year operating...
Study smarter with the SolutionInn App