-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC# 101 - HW2.cs
80 lines (73 loc) · 2.39 KB
/
C# 101 - HW2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// See https://aka.ms/new-console-template for more information
using System;
namespace operatorler
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("----Atama ve İşlemli Atama Operatörleri----");
//Atama ve İşlemli atama
//=, +=, -=, *=, /=
int x=3;
int y=3;
y=y+2; //2eklenir çıktı 5 olur
Console.WriteLine(y);
y += 2; //son haline 2 eklenir çıktı 7 olur
Console.WriteLine(y);
y /=1; //son hali 1e bölünür çıktı 7 olur
Console.WriteLine(y);
x *=2; //son hali 2ile çarpılır çıktı 6 olur
Console.WriteLine(x);
Console.WriteLine("----Mantıksal Operatörler----");
//Matıksal Operatörler
//&&, ||, !
bool isSuccess=true;
bool isCompleted=false;
if(isSuccess && isCompleted )
Console.WriteLine("Perfect!");
if(isSuccess || isCompleted )
Console.WriteLine("Great!");
if(isSuccess && !isCompleted )
Console.WriteLine("Fine!");
Console.WriteLine("----İlişkisel Operatörler----");
//İlişkisel Operatörler
// <, >, <=, >=, ==, !=
int a=3;
int b=4;
bool sonuc=a<b;
Console.WriteLine(sonuc);
sonuc= a>b;
Console.WriteLine(sonuc);
sonuc= a>=b;
Console.WriteLine(sonuc);
sonuc= a<=b;
Console.WriteLine(sonuc);
sonuc= a==b;
Console.WriteLine(sonuc);
sonuc= a!=b;
Console.WriteLine(sonuc);
Console.WriteLine("----Aritmetik Operatörler----");
//Aritmetik Operatörler
// +,*,/,-
int c=5;
int d=10;
float sonuc1;
sonuc1=c/d;
Console.WriteLine(sonuc1);
sonuc1=d/c;
Console.WriteLine(sonuc1);
sonuc1=c+d;
Console.WriteLine(sonuc1);
sonuc1=c*d;
Console.WriteLine(sonuc1);
sonuc1=c-d;
Console.WriteLine(sonuc1);
sonuc1=c++;
Console.WriteLine(C++);
// % işareti mod alır
int sonuc2=20%3;
Console.WriteLine(sonuc2);
}
}
}