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: 77% (9 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?
-
Carver Corporation uses the accrual method of accounting and the calendar year as its tax year. Its board of directors authorizes a cash contribution on November 3 of Year 1, that the corporation...
-
The pressure at which a pure substance changes its phase is known as the (a) Saturated pressure (b) Gauge pressure (c) Absolute pressure (d) None of these.
-
1. What were the goals of installing CRM software? 2. A Siebel executive commented that the companys CRM system does not fit the needs of all clients. He noted that the clients need to decide if they...
-
A conducting spherical shell has inner radius 2 / 3 R and outer radius R . ( a ) Suppose we put a charge Q onthe shell ( a conductor ) so that all of the charge goes to the outer radius. Find the...
-
1. what is the source of wave motion? 2. describe how a wave is different from a pulse. 3. if we double the frequency of a vibrating object, what happens to its period? 4. a railroad locomotive is at...
-
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.
-
Briefly discuss the three ways that a spouse can request relief from joint and several liability.
-
A boat travels \(25 \mathrm{mph}\) relative to the riverbank while going downstream and only \(15 \mathrm{mph}\) returning upstream. What is the boat's speed in still water?
-
Jerry is given the option of a straight salary of \(\$ 4,600 /\) week (no commission option), or a salary of \(\$ 1,000 /\) week plus \(15 \%\) of the weekly sales. How many sales are necessary for...
-
Beams of light parallel to the axis of the parabolic mirror shown in Figure 15.44 strike the mirror and are reflected. Find the distance from the vertex to the point where the beams concentrate....
-
Read the "What in the World?" at the beginning of this chapter. Rank teams A, B, C, D, E, and F if you are given the following information. Team A beats F, and ties \(\mathrm{C}\) and \(\mathrm{D}\);...
-
Find the value of each function in Problems 14-17. \(m(x)=5\); find \(m(10)\).
-
The following table provides information on planned and actual inputs and outputs of an automotive service center in terms of standard hours of work. The beginning backlog is 14 standard hours of...
-
The manager for retail customers, Katie White, wants to hear your opinion regarding one business offer she has received from an entrepreneur who is starting a mobile phone app called Easy Money. The...
-
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.
-
On January 1 of Year 1, Innovative Lab issued a 4-year $50,000 note to a local bank with fixed interest payments based on 6%, payable annually on December 31. To hedge the risk of a fixed interest...
-
Part 4 Tennis company, a distributor of Tennis Rackets, has been experiencing losses for some time, as shown by its most recent monthly contribution format income statement below: Sales Variable...
-
Bunnell Corporation is a manufacturer that uses job-order costing. On January 1, the company's inventory balances were as follows: Raw materials Work in process Finished goods $ 59,500 $ 37,600...
Study smarter with the SolutionInn App