-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperatorsCommandLineArgs.cs
91 lines (75 loc) · 2.88 KB
/
OperatorsCommandLineArgs.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
81
82
83
84
85
86
87
88
89
90
91
//C# Basics
using System;
namespace Practice
{
class Program
{
static void Main(string[] args)
{
int a,b;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
//Formatting : How output can be formatted
Console.WriteLine(
format: "{0} {1,5:NO}", //how output will be shown
arg0: b*a, //what is 1st argument
arg1:b*b //what is 2nd arg....
) ;
//operators in C#
//Binary
Console.WriteLine(plus(a, b));
Console.WriteLine(minus(a, b));
Console.WriteLine(multiply(a, b));
Console.WriteLine(divide(a, b));
//Unary Prefic INc
Console.WriteLine(($"Value of ++a , {++a}"));
Console.WriteLine(($"Value of a , {a}"));
//Unary- Postfix Increment
Console.WriteLine(($"Value of a++ before maintaining buffer , {a++}")); //will output value of a
Console.WriteLine(($"Value of a++ after maintaining buffer ,{a}")); //will output value of a
//Unary - Prefix dec
Console.WriteLine(($"Value of --a , {--a}")); //will output value of a
Console.WriteLine(($"Value of a ,{a}")); //will output value of a
//Unary- Postfix Dec
Console.WriteLine(($"Value of a-- {a--}")); //will output value of a
Console.WriteLine(($"Value of a {a}")); //will output value of a
int c=3;
Console.WriteLine($"Value of c*=a, c is 3 {c*=a}");
Console.WriteLine($"Value of c, c is no a*c when c =3 --> {c}");
//logical operators
Console.WriteLine("Enter your age : ");
int age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your name : ");
string name = Console.ReadLine();
char[] nameArr = new char[name.Length];
foreach(var i in nameArr)
{
nameArr[i] = name[i]; //copying string to char array --> Assignment operator
}
if((nameArr[0]=='S' || nameArr[0]=='s') && age>18)
{
Console.WriteLine("You are eligible for CNIC ");
}
else
{
Console.WriteLine("Not eligible");
}
}
static int plus(int a,int b)
{
return a + b;
}
static int minus(int a, int b)
{
return a - b;
}
static int multiply(int a, int b)
{
return a * b;
}
static int divide(int a, int b)
{
return a / b;
}
}
}