Sunday, March 20, 2011

Assignment On Basics


2.1. Every C# program requires at least one main static class. (True/False)
2.2. Booleans are only 1 bit in size. (True/False)
2.3. Unsigned integers can hold numbers up to around 4 billion. (True/False)
2.4. Floating point numbers hold exact representations of numbers. (True/False)
2.5. Why can’t you use variables before they have been assigned a value?
2.6. Why do constants make your programs easier to read?
2.7. Is the following code valid?
int x = 10;
float y = 20;
x = y;
(Yes/No)
2.8. What is the value of x after this code is done?
int x = 10;
if( x == 10 )
x = 20;
2.9. Assume that c is 0.What are the values of the variables after this code is done,
and why?
int w = 0, x = 0, y = 0, z = 0;
switch( c )
{
case 0:
w = 10;
case 1:
x = 10;
case 2:
y = 10;
break;
case 3:
z = 10;
break;
}

32 Chapter 2 _ The Basics
2.10. Now assume that c is 2 and the code from Question 2.9 is run again.What are
the values of the variables w, x, y, and z?
2.11. Does the computer compare the value of x and 10 in this example?
int x = 10, y = 20;
if( y == 20 && x == 10 )
x = 20;
2.12. Does the computer compare the value of x and 10 in this example?
int x = 10, y = 20;
if( y == 20 || x == 10 )
x = 20;
2.13. When this code is completed, what is the value of x?
int x = 0;
while( x < 10 )
x++;
2.14. For each loop, does the value of x increase before FunctionA executes or after it executes?
for( int x = 0; x < 10; x++ )
{
FunctionA();
}
2.15. Rewrite the code in Question 2.14 using a while loop instead.
2.16. How many times is FunctionA executed?
int x = 0;
do
{
FunctionA();
} while( x == 1 );
2.17. What is the value of x after the following code is done?
int x = 0;
for( int y = 0; y < 10; y += 2 )
{
if( y == 4 )
break;
x++;
}
2.18.What is the value of x after the following code is done?
int x = 0;
for( int y = 0; y < 10; y += 2 )
{
if( y == 4 )
continue;
x++;
}
2.19. Is this code valid? (Assume that FunctionA exists.)
for( int y = 0; y < 10; y++ )
{
FunctionA();
}
y = 0;

No comments:

Post a Comment

Your comment is pending for approval

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...