Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Operators and Programming Constructs pot
MIỄN PHÍ
Số trang
30
Kích thước
876.3 KB
Định dạng
PDF
Lượt xem
750

Operators and Programming Constructs pot

Nội dung xem thử

Mô tả chi tiết

Operators and

Programming

Constructs

Chapter 3

Operators are used to compute results and compare

the data values of a program. A program often

involves

decision-making and iterative tasks. To accomplish

these tasks, programmers use various operators in

the conditional and looping constructs.

This chapter discusses the types of operators used in

C# language. In addition, the conditional constructs

and the looping constructs are also discussed.

In this chapter, you will learn to:

 Use various operators:

z Arithmetic

z Arithmetic assignment

z Unary

z Comparison

z Logical

 Use conditional constructs

 Use looping constructs

Objectives

¤NIIT Operators and Programming Constructs 3.3

Applications use operators to process the data entered by a user. Operators like + and - are

used to process variables and return a value. An operator is a set of one or more characters

that is used for computations or comparisons. Operators can transform one or more data

values, called operands, into a new data value.

Consider the following expression:

X+Y

The preceding expression uses two operands and an operator to add the values stored in

the variables.

Operators in C# can be classified as follows:

„ Arithmetic operators

„ Arithmetic assignment operators

„ Unary operators

„ Comparison operators

„ Logical operators

These operators are the symbols that are used to perform arithmetic operations on

variables. The following table describes the commonly used arithmetic operators.

Operator Description Example

+ Used to add two

numbers

X=Y+Z;

If Y is equal to 20 and Z is equal to 2, X will

have the value 22.

- Used to subtract two

numbers

X=Y-Z;

If Y is equal to 20 and Z is equal to 2, X will

have the value 18.

* Used to multiply two

numbers

X=Y*Z;

If Y is equal to 20 and Z is equal to 2, X will

have the value 40.

Using Operators

Arithmetic Operators

Tải ngay đi em, còn do dự, trời tối mất!