20150908 Statement and operator

Source: Internet
Author: User
Tags arithmetic operators

Statement:
Conditional operator:?:

Conditional statement: Implementing a selection Branch
if (conditional expression)

{
...
}

Looping statements: Implementing repetitive operations

Jump statement: End loop

Exception statement:

Operator:

Arithmetic operators: +-*/% + +--

Comparison operator: < > <= >= = = =!

Logical operators: && | | !


Precedence of the operation: parentheses within the first parentheses

Before + + before--
* / %
+ -
> < >= <= = = =!
&& | |
!

#region = = Arithmetic operator = =

int A, b, C;
A = a + B; When the value in the original A is added to the value in B, the result is assigned to a
a++;//a=a+1;
A--;//a=a-a;
++a;
--a;
int d = a++;//after the execution of the statement after the execution of the order is int d=a; a=a+1;
int e = ++a;//Pre-Gaga execution order before statement execution is a=a+1; int e =a;

#endregion

#region = = comparison operator = =

int A, B;
Console.Write ("Input A:");
A = Convert.ToInt16 (Console.ReadLine ());
Console.Write ("Input B:");
b = Convert.ToInt16 (Console.ReadLine ());

BOOL C = a > b;//determine if A is greater than B. The comparison expression returns a bool value
Console.WriteLine (c);

#endregion

#region = = logical operator = =
while (true)//infinite Dead loop
{
int A, b, C;
Console.Write ("Input a");
A = Convert.ToInt16 (Console.ReadLine ());
Console.Write ("Input B:");
b = Convert.ToInt16 (Console.ReadLine ());
Console.Write ("Input C:");
c = convert.toint16 (Console.ReadLine ());

BOOL E = a > B && a > C;
BOOL F =! (A > B && a > C);//The meaning of the inverse value
Console.WriteLine (e);

Console.ReadLine ();
}
#endregion

The use of #region = = =
int A, b, C;
Console.Write ("Input a");
A = Convert.ToInt16 (Console.ReadLine ());
Console.Write ("Input B:");
b = Convert.ToInt16 (Console.ReadLine ());

string s = a > B? "A>b": "A<b"; If A>b is displayed when A>B is established, the reverse is displayed a<b
Console.WriteLine (s);
#endregion

20150908 Statement and operator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.