Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace generate_prime_nos
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. bool current=false;
  13. int j;
  14. Console.WriteLine("Enter a number");
  15. int num=Int32.Parse(Console.ReadLine());
  16. Console.WriteLine("The prime numbers are: ");
  17. for (int i = 2; i <= num; i++)
  18. {
  19. for (j = 2; j < i; j++)
  20. {
  21. if (i % j == 0)
  22. {
  23. current = true;
  24. break;
  25. }
  26. }
  27. if (current == false)
  28. {
  29. Console.Write("{0}", j);
  30.  
  31.  
  32.  
  33. }
  34. else
  35. {
  36. current = false;
  37. }
  38. }
  39. Console.ReadLine();
  40.  
  41. }
  42. }
  43. }
  44.  
  45. using System;
  46. using System.Collections.Generic;
  47. using System.Linq;
  48. using System.Text;
  49.  
  50. namespace Reverse
  51. {
  52. class Program
  53. {
  54. static void Main(string[] args)
  55. {
  56. int n,m;
  57. int sum = 0;
  58. int rev = 0;
  59. Console.WriteLine("Enter a number");
  60. n = Convert.ToInt32(Console.ReadLine());
  61. while(n>0)
  62. {
  63. m=n%10;
  64. sum += m;
  65. rev = rev *10 + m;
  66. n=n/10;
  67. }
  68. Console.WriteLine("The reverse of the number is:{0}",rev);
  69. Console.WriteLine("The sum of the digit is:{0}",sum);
  70. Console.ReadLine();
  71. }
  72. }
  73. }
  74.  
  75. using System;
  76. using System.Collections.Generic;
  77. using System.Linq;
  78. using System.Text;
  79.  
  80. namespace vowel
  81. {
  82. class Program
  83. {
  84. static void Main(string[] args)
  85. {
  86. Console.WriteLine("Enter any character");
  87. char c = Convert.ToChar(Console.ReadLine());
  88. {
  89. if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
  90. {
  91. Console.WriteLine("The entered character is a vowel");
  92. }
  93. else
  94. Console.WriteLine("The entered character is not a vowel");
  95. c=Convert.ToChar(Console.ReadLine());
  96. {
  97. Console.ReadKey();
  98. }
  99. }
  100. }
  101. }
  102. }
  103.  
  104. using System;
  105. using System.Collections.Generic;
  106. using System.Linq;
  107. using System.Text;
  108.  
  109. namespace foreachloop
  110. {
  111. class Program
  112. {
  113. static void Main(string[] args)
  114. {
  115. int[] numbers = { 4, 5, 6, 1, 2, 3, -1, -2, -3, 0 };
  116. foreach(int i in numbers)
  117. {
  118. Console.WriteLine(i);
  119. Console.ReadLine();
  120.  
  121. }
  122. }
  123. }
  124. }
  125.  
  126.  
  127. using System;
  128. using System.Collections.Generic;
  129. using System.Linq;
  130. using System.Text;
  131.  
  132. namespace nestedclass1
  133. {
  134. public class outer
  135. {
  136. public outer(int num)
  137. {
  138. Number = num;
  139. }
  140. public void DisplayNumber()
  141. {
  142. Console.WriteLine("The outher class Number: " + Number);
  143. Console.ReadLine();
  144. }
  145. public class Inner
  146. {
  147. public void DisplayNumber(outer o)
  148. {
  149. Console.WriteLine("The Inner class Number is :" + o.Number);
  150. Console.ReadLine();
  151. }
  152. }
  153. private int Number;
  154.  
  155. }
  156. public class program
  157. {
  158. static void Main(string[] args)
  159. {
  160. outer o1 = new outer(100);
  161. o1.DisplayNumber();
  162. outer.Inner i1 = new outer.Inner();
  163. i1.DisplayNumber(o1);
  164. }
  165. }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement