Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace lesson4operators
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine(5);
  14. Console.WriteLine(+5);
  15. Console.WriteLine(5 + 5);
  16. Console.WriteLine(5 + .5);
  17. Console.WriteLine("5" + "5");
  18. Console.WriteLine("5" + 5);
  19.  
  20.  
  21. Console.WriteLine("minus section");
  22. int a = 5;
  23. Console.WriteLine(a - 1);
  24. Console.WriteLine(-a);
  25.  
  26. Console.WriteLine("wth is negation operator used for?");
  27.  
  28. Console.WriteLine("double") //i dont understand double. why cant i use int?
  29. ; double x = 1.5; //why does it need a semicolon at the beginning?
  30. Console.WriteLine(x);
  31. Console.WriteLine(x++);
  32. Console.WriteLine(x);
  33. Console.WriteLine(++x);
  34. Console.WriteLine(x);
  35.  
  36.  
  37. Console.WriteLine("if");
  38. int b = 2;
  39. Console.WriteLine(b);
  40. Console.WriteLine(++b);
  41. if (b > 2)
  42. {
  43. Console.WriteLine("b is greater than 2");
  44. }
  45. else
  46. {
  47. Console.WriteLine("b is less and or equal to 2");
  48. }
  49.  
  50. Console.WriteLine("nested if");
  51. int c = 10;
  52. int d = 8;
  53. if (c > 9)
  54.  
  55. {
  56. if (d > 9)
  57. Console.WriteLine("result 1");
  58. }
  59. else
  60. {
  61. Console.WriteLine("result 2");
  62. }
  63.  
  64. if (c > 9)
  65.  
  66. {
  67. if(d > 9)
  68. Console.WriteLine("result 1");
  69. }
  70. else
  71. {
  72. Console.WriteLine("result 2"); //why don't two 'result 2's appear ?
  73. }
  74.  
  75.  
  76. Console.WriteLine("totally modulus dood");
  77. Console.WriteLine(5 % 2);
  78. Console.WriteLine(5 % 2.2);
  79. Console.WriteLine(5 % 5);
  80.  
  81. //ignore shifts?
  82.  
  83. Console.WriteLine(1 is int);
  84. Console.WriteLine("dog" is int); //these say always and never so im not sure when its supposed to be used
  85.  
  86. Console.ReadLine();
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement