Wednesday, June 3, 2009

C# applications

1. Select the matching word, phrase or acronym for each question.
A. colon
B. Main
C. blank lines
D. if
E. newline
F. Console.Write
G. keywords
H. brace
I. EOF
J. //
K. start
L. comma
M. STX
N. semicolon


ABCDEFGHIJKLMNMost C# statements end with a(n) ____.
ABCDEFGHIJKLMN____ are reserved for use by C#.
ABCDEFGHIJKLMNA left ____ begins the body of every method and a right ____ ends the body of every method.
ABCDEFGHIJKLMNNewline, space and tab characters and ____ are called whitespace characters.
ABCDEFGHIJKLMNMethods WriteLine and ____ display information in the console window.
ABCDEFGHIJKLMNThe escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen.
ABCDEFGHIJKLMN____ begins a single-line comment.
ABCDEFGHIJKLMNThe ____ statement is used to make decisions.
ABCDEFGHIJKLMNC# applications begin execution at method ____.
Points Earned: 8.0/8.0
Correct Answer(s): brace : A left ____ begins the body of every method and a right ____ ends the body of every method., semicolon : Most C# statements end with a(n) ____., newline : The escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen., if : The ____ statement is used to make decisions., // : ____ begins a single-line comment., blank lines : Newline, space and tab characters and ____ are called whitespace characters., keywords : ____ are reserved for use by C#., Main : C# applications begin execution at method ____., Console.Write : Methods WriteLine and ____ display information in the console window.




2. Match the correct C# statements to each programming task.
A. Console.Write( "Enter an integer: " );
B. Console.WriteLine( "{0}\n{1}", "This is a Visual C++", "program" );
C. int c, thisIsAVariable, q76354, number;
D. if ( number != 7 ) Console.WriteLine( "The variable number is not equal to 7" );
E. age = Convert.ToInt32(Console.ReadLine() );
F. Console.WriteLine( "This\tis\ta\tVisual\tC++\tprogram\n" );
G. Console.WriteLine( "This is a Visual C++ program\n" );
H. Console.WriteLine( "This\nis\na\nVisual\nC++\nprogram\n" );
I. Console.WriteLine( "This is a Visual C++\nprogram\n" );


ABCDEFGHIInput an integer from the user at the keyboard and store it in integer variable age.
ABCDEFGHIPrompt the user to enter an integer.
ABCDEFGHIDeclare the variables c, thisIsAVariable, q76354 and number to be of type int.
ABCDEFGHIPrint the message "This is a Visual C++ program". Separate each word from the next by a tab.
ABCDEFGHIPrint the message "This is a Visual C++ program" on two lines using a single statement and a single string. End the first line with C++.
ABCDEFGHIPrint the message "This is a Visual C++ program" with each word on a separate line.
ABCDEFGHIPrint the message "This is a Visual C++ program" on one line.
ABCDEFGHIIf the variable number is not equal to 7, print "The variable number is not equal to 7".
ABCDEFGHIPrint the message "This is a Visual C++ program" on two lines using a single statement and two format items. End the first line with C++.
Points Earned: 8.0/8.0
Correct Answer(s): int c, thisIsAVariable, q76354, number; : Declare the variables c, thisIsAVariable, q76354 and number to be of type int., Console.Write( "Enter an integer: " ); : Prompt the user to enter an integer., age = Convert.ToInt32(Console.ReadLine() ); : Input an integer from the user at the keyboard and store it in integer variable age., if ( number != 7 ) Console.WriteLine( "The variable number is not equal to 7" ); : If the variable number is not equal to 7, print "The variable number is not equal to 7"., Console.WriteLine( "This is a Visual C++\nprogram\n" ); : Print the message "This is a Visual C++ program" on two lines using a single statement and a single string. End the first line with C++., Console.WriteLine( "{0}\n{1}", "This is a Visual C++", "program" ); : Print the message "This is a Visual C++ program" on two lines using a single statement and two format items. End the first line with C++., Console.WriteLine( "This\tis\ta\tVisual\tC++\tprogram\n" ); : Print the message "This is a Visual C++ program". Separate each word from the next by a tab., Console.WriteLine( "This is a Visual C++ program\n" ); : Print the message "This is a Visual C++ program" on one line., Console.WriteLine( "This\nis\na\nVisual\nC++\nprogram\n" ); : Print the message "This is a Visual C++ program" with each word on a separate line.




3. Assume the using std::cout; statement appears at the beginning of your program. Which of these statements are true and which are false?
A. True
B. False
C. Not able to say


ABCComments cause the computer to print the text after the // on the screen when the application is executed.
ABCC# considers the variables Number and NuMbEr to be identical.
ABCThe remainder operator (%) can be used only with integer operands.
ABCThe escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
ABCAll variables must be declared before they are used.
ABCAll variables must be given a type when they are declared.
ABCThe arithmetic operators *, /, %, + and - all have the same level of precedence.
Points Earned: 6.0/6.0
Correct Answer(s): False : Comments cause the computer to print the text after the // on the screen when the application is executed., False : C# considers the variables Number and NuMbEr to be identical., False : The remainder operator (%) can be used only with integer operands., True : The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen., True : All variables must be declared before they are used., True : All variables must be given a type when they are declared., False : The arithmetic operators *, /, %, + and - all have the same level of precedence.




4. Match the correct C# statement (or comment) to each programming task.
A. int x; int y; int z; int result;
B. Console.OutLine( "Enter the first integer: " );
C. z = Convert.ToInt32(Console.ReadLine() );
D. y = Console.ReadLine();
E. // Calculate the product of three integers.
F. Console.WriteLine( "Enter the first integer: " );
G. Console.WriteLine( "Enter the second integer: " );
H. Console.WriteLine( "The product is {0}", result );
I. Console.OutLine( "Enter the third integer: " );
J. result = x # y # z;
K. y = Convert.ToInt32(Console.ReadLine() );
L. z = Console.ReadLine();
M. Console.WriteLine( "cin >> x >> y >> z" );
N. result = x * y * z;
O. x = Console.ReadLine();
P. Console.WriteLine( "Enter the third integer: " );
Q. int x, int y, int z, int result;
R. x = Convert.ToInt32(Console.ReadLine() );
S. Console.OutLine( "Enter the second integer: " );
T. Console.WriteLine( "The product is result" );
U. *** Calculate the product of three integers. ***


ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the third integer. Leave the cursor at the end of the line.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable z.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable y.
ABCDEFGHIJKLMNOPQRSTUPrint "The product is " followed by the value of the variable result.
ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the second integer. Leave the cursor at the end of the line.
ABCDEFGHIJKLMNOPQRSTUState that a program calculates the product of three integers.
ABCDEFGHIJKLMNOPQRSTUDeclare the variables x, y, z and result to be of type int (in separate statements).
ABCDEFGHIJKLMNOPQRSTUCompute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable x.
ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the first integer. Leave the cursor at the end of the line.
Points Earned: 9.0/10.0
Correct Answer(s): // Calculate the product of three integers. : State that a program calculates the product of three integers., int x; int y; int z; int result; : Declare the variables x, y, z and result to be of type int (in separate statements)., Console.WriteLine( "Enter the first integer: " ); : Prompt the user to enter the first integer. Leave the cursor at the end of the line., x = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable x., Console.WriteLine( "Enter the second integer: " ); : Prompt the user to enter the second integer. Leave the cursor at the end of the line., y = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable y., Console.WriteLine( "Enter the third integer: " ); : Prompt the user to enter the third integer. Leave the cursor at the end of the line., z = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable z., result = x * y * z; : Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result., Console.WriteLine( "The product is {0}", result ); : Print "The product is " followed by the value of the variable result.

No comments:

Post a Comment