Programming Output and Input Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

int y = 4 % 2; y++; Console.Write(y); 1 2 0 No Output Error None of the above

1, % operator returns the remainder of the division of 4 by 2, which is 0

string x = "1"; char y = '6'; Console.Write(x + y); 6 16 61 No output Error None of the above

16

string x = "1"; int y = 6; Console.Write(x + y); 6 16 61 No output Error None of the above

16, treats it as a string

int sum = (2 + 2 + 1); int average = sum / 2; Console.Write(average); 5 2 2.5 No Output Error None of the above

2, int cannot be a decimal

Console.WriteLine(3); 3 No output Error None of the above

3

string x = Console.ReadLine( ); x = "3"; Console.Write(x); 3 [anything user enters] b No Output Error None of the above

3

int x = 5; x--; Console.Write(x); 3 2 4 No Output Error None of the above

4

string x = Console.ReadLine(); Console.Write(5); b 5 [anything user enters] No Output Error None of the above

5

int x = 5; x = 6; x = 4 + 3; Console.Write(x); 6 5 7 No Output Error None of the above

7

int x = 5; x = x + 1; x++; Console.Write(x); 6 7 5 No Output Error None of the above

7

int x = 1; int y = 6; Console.Write((x + y)); 6 7 No output Error None of the above

7, order of operations

Which operator can be used to compare two values? >< == = <> None of the above

==

Which operator is used to multiply numbers? x # * % None of the above

*

How do you insert COMMENTS in C# code? // This is a comment # This is a comment /* This is a comment All of the above None of the above

// This is a comment

Console.Write(1); 1 No output Error None of the above

1

Console.WriteLine(23.5); 24 23 No output Error None of the above

None of the above, answer is 23.5

Which operator is used to add together two values? The + sign The * sign The & sign All of the above None of the above

The + sign

The Console.WriteLine() method can be used to display multiple values on the console using string concatenation True False

True

Variables need to be initialized. The computer will not assume a value for your variable and will complain if you use a variable that has no value. True False

True

Variables represent a place to store information so the computer can work with it True False

True

string x = Console.ReadLine(); x = "3"; Console.Write(x); string x = Console.ReadLine(); 3 [anything user enters] No Output Error None of the above

Error, x was already declared

How do you create a variable with the decimal number 2.8? float x = 2.8f; decimal x = 2.8m; double x = 2.8; All of the above None of the above

All of the above

Programming languages have a basic set of supported data types that hold values, this basic set of data types is referred to Simple types Pre-defined types Primitive types All of the above None of the above

All of the above

char z = 'Z'; string x = "BM" + z; Console.Write(x); Z BMZ BM No Output Error None of the above

BMZ

What is a correct syntax to output "Hello World" in C#? print("Hello World"); Console.WriteLine("Hello World"); System.out.println("Hello World"); echo("Hello World"); console.Write("Hello World"); All of the above None of the above

Console.WriteLine("Hello World");

char x = 0; 0 x No Output Error None of the above

Error

string x = "4"; Console.Write(x++); 4 5 No output Error None of the above

Error, ++ cannot be applied to a string

int x = 23.5; Console.WriteLine(x); 24 23 No output Error None of the above

Error, 23.5 isn't an integer

string x = "1"; char y = 6; Console.Write(x + y); 6 16 61 No output Error None of the above

Error, 6 needs to be in single quotes

decimal y = 3.5 m; int x = y + 2; Console.Write(x); 5.5 5 No Output Error None of the above

Error, can't add decimal to int

int x = true; int y = 6; Console.Write(x + y); 6 7 False True No output Error None of the above

Error, can't apply true to an integer type

string data = "4"; int x = data * 3; Console.WriteLine(x); 3 12 No Output Error None of the above

Error, can't do * between string and int

string = "4"; Console.Write(string); 4 No output Error None of the above

Error, cannot use string as a variable name

message = "hello world"; Console.WriteLine(message); message hello world No Output Error None of the above

Error, could be fixed by putting string before message

Double x = 23.5; Console.WriteLine(x); 24 23 No output Error None of the above

Error, data types need to be lower case

int x = 0; int x = 1; 0 1 No Output Error None of the above

Error, declaring x twice

string y = '4'; Console.Write(y); 4 No output Error None of the above

Error, needs double quotes

int x; Console.WriteLine(x); 0 x No Output Error None of the above

Error, never assigned a value to x

Console.Write(x); x No output Error None of the above

Error, never defined x

Console.WriteLine("hello"); hello! Hello No Output Error None of the above

Error, no ;

int x = Console.ReadLine(); Console.WriteLine(x); [anything user enters] b No Output Error None of the above

Error, readline results in a string not an int

bool x = true; Console.Write(bool); True False No output Error None of the above

Error, should be x in second line, bool is not the data type

int x = "10"; x 10 No Output Error None of the above

Error, shouldn't have ""

string x = 2; Console.WriteLine(x++); 3 No output Error None of the above

Error, string needs double quotes

Console.write("hello"); Console.write("world"); hello hello world No Output Error None of the above

Error, write is not capitalized

Console.write(4); Console.write(5); 4 5 45 No output Error None of the above

Error, write not capitalized

int x = 0; x = 3.4; 3.4 0 No Output Error None of the above

Error, x is an int and 3.4 is not

Console.WriteLine(3); Console.WriteLine(x); 0 3 No output Error None of the above

Error, x is undefined

A variable of type bool can be used to store numerical values. True False

False

A variable of type char can store multiple characters True False

False

A variable of type string can store any type of data, including numbers and booleans True False

False

The Console.ReadLine method can only be used to read a single character input from the user True False

False

The Console.ReadLine() method automatically converts user input to the appropriate data type True False

False

The Console.Write() method automatically adds a new line at the end of the output True False

False

The Console.WriteLine() method can only be used to display strings True False

False

The ability to read between the lines and determine what was meant rather than what was said is a skill computers are best suited for. True False

False

To initialize a variable means to assign it an initial type only. True False

False

bool x = false; Console.Write(x); 0 1 True False No output Error None of the above

False or false

Every variable must only have two things: a value and a name. True False

False, also has a type

The value of a string variable can be surrounded by single quotes. True False

False, double quotes

Declaring a variable means to introduce a new variable to the program. You define its value and its name only. True False

False, you assign its TYPE and name

A variable data-type defines the value of data the variable will hold. True False

Fasle

Console.ReadLine(); [anything user enters] b No Output Error None of the above

No Output

int x = 0; int X = 4; 4 0 No Output Error None of the above

No Output

int x = 1; 1 No output Error None of the above

No output

double x = 23.5; Console.WriteLine(x); 24 23 No output Error None of the above

None of the above, 23.5

A programming language is set of rules that provides a way of telling a computer what operations to perform, communicate an algorithm, or receive an input from the user and generates an output. True False

True

Assigning to a variable means to provide the variable with a value. True False

True

How do you create a variable with the numeric value 5? int x = 5; num x = 5 Integer x = 5; x = 5; All of the above None of the above

int x = 5

Which data type is used to create a variable that should store text? myString Txt string All of the above None of the above

string


Set pelajaran terkait

Artificial Intelligence: A Modern Approach Chapter 2 Intelligent Agents

View Set

Chapter 2: Client care and Body Systems - Practice Exercise

View Set

Chapter 24: Using Nursing Research in Practice: 8th edition

View Set

BACTERIAL CAUSES OF SORE THROAT I: Streptococcus

View Set

ACT 101 Chapter 9 Cash Receipts, Cash Payments, and Banking Procedures

View Set

ATP 7-22.01: HOLISTIC HEALTH AND FITNESS TESTING

View Set

A03 - eLearning - Math: Fractions and Decimals 111

View Set