Chapter 4 Control Structures: Part 1 135 i) (Vps web hosting)
Chapter 4 Control Structures: Part 1 135 i) The increment operator (++) and decrement operator (–) increment and decrement a variable s value by . j) Explicit conversion makes use of the operator. 4.2 State whether each of the following is true or false. If false, explain why. a) It is difficult to convert pseudocode into a working C# program. b) Sequential execution refers to statements in a program that execute one after another. c) It is recommended for C# programmers to use goto statements. d) The ifstructure is called a single-selection structure. e) Structured programs are clear, easy to debug and modify and more likely than unstruc tured programs to be bug-free in the first place. f) The sequence structure is not built into C#. g) Pseudocode usually resembles actual C# code. h) Placing a semicolon after the condition in an if structure is a syntax error. i) The whilestructure body may be a single or a block. 4.3 Write four different C# statements that each add 1 to integer variable x and store the result in x. 4.4 Write C# statements to accomplish each of the following: a) Assign the sum of xand yto z then increment x by 1 after the calculation. Use only one statement. b) Test if the value of the variable count is greater than 10. If it is, print “Count is greaterthan10″. c) Decrement the variable x by 1, then subtract it from the variable total. Use only one statement. d) Calculate the remainder after qis divided by divisorand assign the result to q. Write this statement two different ways. 4.5 Write a C# statement to accomplish each of the following tasks: a) Declare variables sumand xto be of type int. b) Assign 1 to variable x. c) Assign 0 to variable sum. d) Add variable x to variable sum and assign the result to variable sum. e) Print “Thesumis:” followed by the value of variable sum. 4.6 Combine the statements that you wrote in Exercise 4.5 into a C# application that calculates and prints the sum of the integers from 1 to 10. Use the while structure to loop through the calculation and increment statements. The loop should terminate when the value of x becomes 11. 4.7 Determine the values of each variable after the calculation is performed. Assume that when each statement begins executing, all variables have the integer value 5. a) product *= x++; b) quotient /= ++x; 4.8 Identify and correct the errors in each of the following: a) while ( c <= 5 ) { product *= c; ++c; b) if ( gender == 1 ) Console.WriteLine( "Woman" ); else; Console.WriteLine( "Man" );
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services