Online English Summarizer tool, free and accurate!
Introduction to computer systems
CSC 115
Primitive Data
Types and Variables
How Computing Works?Console.WriteLine("a+b={0} sum={1} equal={2}",
a+b, sum, equal);
41
Decimal Floating-Point Types
? There is a special decimal floating-point
real number type in C#:
? decimal (+-1,0 x 10-28 to +-7,9 x 1028): 128-bits,
precision of 28-29 digits
? Used for financial calculations
? No round-off errors
? Almost no loss of precision
? The default value of decimal type is:
? 0.0M (M is the suffix for decimal numbers)
42
The Boolean Data Type
? The Boolean data type:
? Is declared by the bool keyword
? Has two possible values: true and false
? Is useful in logical expressions
? The default value is false
43
Boolean Values - Example
? Example of boolean variables taking values of
true or false:
int a = 1;
int b = 2;
bool greaterAB = (a > b);
Console.WriteLine(greaterAB); // False
bool equalA1 = (a == 1);
Console.WriteLine(equalA1); // True
44
The Character Data Type
? The character data type:
? Represents symbolic information
? Is declared by the char keyword
? Gives each symbol a corresponding integer code
? Has a '\0' default value
? Takes 16 bits of memory (from U+0000 to
U+FFFF)
45
Characters and Codes
? The example below shows that every symbol
has an its unique Unicode code:
char symbol = 'a';
Console.WriteLine("The code of '{0}' is: {1}",
symbol, (int) symbol);
symbol = 'b';
Console.WriteLine("The code of '{0}' is: {1}",
symbol, (int) symbol);
symbol = 'A';
Console.WriteLine("The code of '{0}' is: {1}",
symbol, (int) symbol);
46
The String Data Type
?class_"A"? point9 ? Declaring Variables
? When declaring a variable we:
? Specify its type
? Specify its name (called identifier)
? May give it an initial value
? The syntax is the following:
? Example:
<data_type>
Introduction to computer systems
CSC 115
Primitive Data
Types and Variables
How Computing Works?
Computers are machines that process data
Data is stored in the computer memory in
variables
Variables have data type, name and value
Example of variable definition and assignment
in C#
int count = 5;
Data type
Variable name
Variable value
3
What Is a Data Type?
A data type:
Is a domain of values of similar characteristics
Defines the type of information stored in the
computer memory (in a variable)
Examples:
Positive integers: 1, 2, 3, …
Alphabetical characters: a, b, c, …
4
Data Type Characteristics
A data type has:
Name (C# keyword ---- int, double)
Size (how much memory is used)
Default value
Example:
Integer numbers in C#
Name: int
Size: 32 bits (4 bytes)
Default value: zero
5
Overview of Common Type System (CTS
CTS supports both value and reference types
Reference Type
Type
Value Type
Comparing Value and
Reference Types
◼ Value types:
◼ Directly contain
their data
◼ Each has its own
copy of data
◼ Operations on one
cannot affect
another
◼ Reference types:
◼ Store references to their
data (known as objects)
◼ Two reference variables
can reference same
object
◼ Operations on one can
affect another
Comparing Built-in and UserDefined Value Types
◼ Examples of
built-in value
types:
◼ Int
◼ double
◼ Examples of user-defined
value types:
◼ enum
◼ struct
User-Defined
Value Types
Built-in Type
Data Types
9
Type Size Description Range
bool 1 byte Store truth value true / false
char 1 byte Store one character character code 0 – 255
byte 1 byte Store positive integer 0 – 255
short 2 byte Store integer -32,768 -- 32,767
int 4 byte Store integer -2.1 x 109
-- 2.1 x 109
long 8 byte Store integer -9.2 x 1018
-- 9.2 x 1018
double 16 byte Store real number ± 5.0x10-324
-- ±
1.7x10308
string N/A Store sequence of
characters
N/A
What are Integer Types?
Integer types:
Represent whole numbers
May be signed or unsigned
Have range of values, depending on the size of
memory used
The default value of integer types is:
0 – for integer types, except
0L – for the long type
10
Integer Types
Integer types are:
sbyte (-128 to 127): signed 8-bit
byte (0 to 255): unsigned 8-bit
short (-32,768 to 32,767): signed 16-bit
ushort (0 to 65,535): unsigned 16-bit
int (-2,147,483,648 to 2,147,483,647): signed
32-bit
uint (0 to 4,294,967,295): unsigned 32-bit
11
Integer Types (2)
More integer types:
long (-9,223,372,036,854,775,808 to
9,223,372,036,854,775,807): signed 64-bit
ulong (0 to 18,446,744,073,709,551,615):
unsigned 64-bit
12
Measuring Time – Example
Depending on the unit of measure we may use
different data types:
byte centuries = 20; // Usually a small number
ushort years = 2000;
uint days = 730480;
ulong hours = 17531520; // May be a very big number
Console.WriteLine("centuries is years, or days, or
hours.", centuries, years, days, hours);
13
Console.ReadLine()
Gets a line of characters
Returns a string value
Returns null if the end of the input is reached
Console.Write("Please enter your first name: ");
string firstName = Console.ReadLine();
Console.Write("Please enter your last name: ");
string lastName = Console.ReadLine();
Console.WriteLine("Hello, ",firstName, lastName);
14
Reading Numeral Types
Numeral types can not be read directly from the
console
To read a numeral type do the following:
Summarize English and Arabic text using the statistical algorithm and sorting sentences based on its importance
You can download the summary result with one of any available formats such as PDF,DOCX and TXT
ٌYou can share the summary link easily, we keep the summary on the website for future reference,except for private summaries.
We are working on adding new features to make summarization more easy and accurate
مرآة البحرين : الصراع في البحرين ليس خلافًا مذهبيًا سطحيًا كما يحاول البعض تصويره، بل هو في جوهره مو...
ستطاعت القوات المسلحة المصرية، خالل السنوات السبع الماضية، أن تحافظ على األمن القومى المصرى فى ظل ا...
في الختام تتوقف هذه التوقعات على الظروف الراهنة والمتغيرات المحتملة في المستقبل. التأثيرات الدقيقة ي...
يعتبر مطعم لذة وصاية وجهة مثالية لعشاق الأطعمة الشرقية والمقبلات الشهية، حيث يجمع بين الأصالة والحدا...
الباب األول أحكام عامة املادة األوىل: أحكام متهيدية أ( تهدف هذه التعليمات إىل تنظيم فتح احلسابات اا...
بِسْمِ اللَّـهِ الرحمن الرَّحِيمِ كلمة الأمين العام لحزب الله سماحة الشيخ نعيم قاسم في الليلة الثالث...
The cows were split into four groups: Group 1 (Double ovisynch): GnRH on day 0, PGF2 on day 7, and G...
Case Study: Liver Disease Fatima, a 42-year-old female, came to the clinic complaining of fatigue, a...
🔴 هروب بارون الصاروخ من مركز الحكمة بئر العاتر وسط تستر أمني مريب ☣️ 🔴 تعود حيثيات القضية إلى ما يقا...
طبعا لم تسلم نظرية الاشتراط الاجرائي لسكنر من بعض الانتقادات ومنها: 1_إهمال النظرية للجانب البيولوجي...
يشهد العالم منذ بداية القرن الحادي والعشرين ثورة معرفية وتكنولوجية، أدت إلى حدوث تغيرات سريعة ومتلاح...
الذكريات السوداء أنا منار عمري عشرون عاما عشت في أيام سوداء تسببت في منحي ذكريات سوداء حاولت نسيانها...