ITELECTIVE2 WEEK2

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

44 Terms

1
New cards

C# SYNTAX

C# code is organized into blocks using braces {} to define scopes of classes, methods, and control structures. These rules help maintain clarity and consistency in code structure.

2
New cards

C# SYNTAX

is influenced by the C and C++ family of languages. Each statement in C# must end with a semicolon. The language is case-sensitive, meaning identifiers like myVariable and MyVariable are treated as distinct.

3
New cards

using System;

allows access to basic libraries

4
New cards

class Program

is a container

5
New cards

Main()

is the entry point of the program

6
New cards

identifiers

In C#, _____ are names given to variables, classes, methods, and other elements. They must start with a letter or an underscore and can contain letters, digits, and underscores.

7
New cards

Keywords

are reserved words in C# like int, string, if, class, and cannot be used as identifiers. Choosing meaningful identifiers improves code readability.

8
New cards

naming conventions

Consistent ____ are essential for readable code. In C#, it is standard to use PascalCase for class and method names, such as CalculateTotal(), and camelCase for variable names, like itemCount.

9
New cards

naming conventions

Constants are usually written in all uppercase letters with underscores, for example, MAX_SIZE. Following conventions helps in collaborative environments and aligns with professional practices.

10
New cards

DATA TYPES IN C#

C# supports several data types, which are divided into value types and reference types.

11
New cards

DATA TYPES IN C#

Value types, such as int, float, bool, and char, store data directly. Reference types, like string, object, arrays, and custom classes, store references to the actual data.

12
New cards

INTEGER TYPES

The most commonly used integer type is int, which occupies 4 bytes and can hold values between -2,147,483,648 and 2,147,483,647. Other integer types include long for larger numbers, short for smaller ranges, and byte for unsigned 8-bit numbers.

13
New cards

FLOATING-POINT TYPES

C# supports float, double, and decimal for real numbers. float uses 4 bytes of memory and requires an f suffix (e.g., 3.14f). double is the default type for floating-point literals and offers more precision. decimal provides even higher precision and is commonly used for financial calculations to avoid rounding errors.

14
New cards

bool type

The_____ can only store two values: true or false. It is commonly used in conditional statements to control program flow.

15
New cards

STRING TYPE

____in C# are a sequence of characters, defined using double quotes, such as "Hello World".

16
New cards

char type

The holds a single Unicode character and is declared using single quotes, for example, 'A'. These types are fundamental in comparison and control expressions.

17
New cards

STRING TYPE

The _____ is a reference type with built-in methods like .Length, .ToUpper(), .ToLower(), and .Substring(). Strings are immutable, meaning they cannot be changed once created; instead, operations return a new string.

18
New cards

VARIABLE DECLARATION AND INITIALIZATION

To use data in your program, you must declare variables with a type and optionally initialize them. You can also declare multiple variables in one.

19
New cards

CONSTANTS

are values that cannot be changed after their declaration. They are defined using the const keyword and must be initialized at the time of declaration, like const double PI = 3.14159;.

20
New cards

readonly

keyword is used for variables whose value is assigned only once, typically at runtime or in the constructor.

21
New cards

TYPE CONVERSION

C# supports implicit and explicit______ _____. Implicit conversion happens automatically when there is no risk of data loss, such as from int to float. Explicit conversion, or casting, is needed when converting from a larger type to a smaller one,

22
New cards

ARITHMETIC OPERATORS

operators allow you to perform calculations within your program.

23
New cards

ARITHMETIC OPERATORS

will assign the value 15 to result. Modulus operator % gives the remainder of division. These are frequently used in loops, conditionals, and algorithmic logic

24
New cards

RELATIONAL OPERATORS

____ ______ compare two values and return a boolean result. For instance, if (x > y) checks if the value of x is greater than y. These operators are vital in decision-making logic within programs, especially inside if and switch statements.

25
New cards

LOGICAL OPERATORS

___ _____ are used to combine multiple conditions. For example, if (x > 5 && y < 10) means the condition will be true only if both comparisons are true. Use || for OR and ! for NOT. Logical operators are crucial when handling complex conditional logic.

26
New cards

CONTROL STRUCTURES

_____ ______ guide the execution flow of a program. In C#, these include decision-making structures (if, else, switch) and looping structures (for, while, do-while, foreach). They allow your program to respond dynamically to input and changing conditions.

27
New cards

If Statement

The _ _____ is the most basic control structure. It checks a condition and executes a block of code if the condition is true. For example:

28
New cards

NESTED IF STATEMENT

You can check multiple conditions using else if. For instance:

29
New cards

SWITCH STATEMENT

The ____ ______ offers a cleaner alternative to multiple if-else statements when comparing a single variable to different constant values. Example:

30
New cards

FOR LOOP

A __ ___s used to repeat a block of code a specific number of times.

31
New cards

WHILE LOOP

A ___ ___runs as long as the condition is true. It is useful when the number of iterations is not known beforehand. Example:

32
New cards

DO-WHILE LOOP

The __ ____ ____ is similar to while, but the condition is checked after the loop body, ensuring the loop runs at least once. Example:

33
New cards

FOREACH LOOP

The ___ ____ is used to iterate over arrays or collections. It simplifies the code and avoids errors from index-based iteration. Example:

34
New cards
35
New cards
36
New cards
37
New cards
38
New cards
39
New cards
40
New cards
41
New cards
42
New cards
43
New cards
44
New cards