|
| 1 | +using System; using System.Collections.Generic; using System.Linq; using System.Text; |
| 2 | + |
| 3 | +namespace FIBO { |
| 4 | + |
| 5 | +class Classi class |
| 6 | + |
| 7 | +public void fibo() { |
| 8 | + |
| 9 | +int I = 0 n * 2 = 1 ,n3,n,6 Console.Writenumber you want fibonacci series?"); nint.Parse(Console.ReadLine()); c = 3 Console.Write(ni+ "\t" + n2); while (c <= n) ( n 3=n1+n2; break; } Console.Write("\t" + n3); n * 1 = n2j n 2=p3; |
| 10 | + |
| 11 | +C++ |
| 12 | + |
| 13 | +} |
| 14 | + |
| 15 | +} public void testprime() { |
| 16 | + |
| 17 | +int n = 0 Console.Write("Enter the no: "); |
| 18 | + |
| 19 | +nint.Parse(Console.ReadLine()); bool flag false; for (int i = 2 i<=n/2; i++) { if (n %10) { flag = true; break; |
| 20 | + |
| 21 | +} |
| 22 | + |
| 23 | +} if (flag) Console.WriteLine("This is not prime number"); else Console.WriteLine("This is prime number"); Console.ReadKey(); |
| 24 | + |
| 25 | +} public void vowel() |
| 26 | + |
| 27 | +{ char[] v = { 'a', 'e', '1', 'o', 'u', 'A', 'E', 'I', '0', 'U' }; Console.Write("Enter a character: "); char c char.Parse(Console.ReadLine()); switch (c) |
| 28 | +{ |
| 29 | +case 'a': |
| 30 | + |
| 31 | +case 'A': |
| 32 | + |
| 33 | +case 'e': |
| 34 | + |
| 35 | +case "E": |
| 36 | + |
| 37 | +case '1': case 'I': |
| 38 | + |
| 39 | +case 'o': |
| 40 | + |
| 41 | +case '0': case 'u': |
| 42 | + |
| 43 | +case 'U': |
| 44 | + |
| 45 | +Console.WriteLine("This is a vowel....."); break; |
| 46 | + |
| 47 | +default: |
| 48 | + |
| 49 | +Console.WriteLine("This is not a vowel....."); break; |
| 50 | + |
| 51 | +} } public void useforeach() { |
| 52 | + |
| 53 | +int[] arr = \{4, 5, 6, 7, 8\} ; foreach () Console.WriteLine(ele + " "); // Console.WriteLine(); |
| 54 | + |
| 55 | +} public void reverseAndSum() |
| 56 | + |
| 57 | +{ |
| 58 | + |
| 59 | +int sum = theta , n = 0 Console.WriteLineEnter the number: "); n = int.Parse(Console.ReadLine()); { int digit temp % 10; |
| 60 | + |
| 61 | +int temp = n; |
| 62 | + |
| 63 | +int rev = theta while (temp > 0) |
| 64 | + |
| 65 | +sum = sum + digit; rev = rev * 10+ digit; |
| 66 | + |
| 67 | +temp temp / 10; |
| 68 | + |
| 69 | +} Console.WriteLine("reverse number is: "+rev); Console.WriteLine("sum of digit number is: "+sum); |
| 70 | + |
| 71 | +} |
| 72 | + |
| 73 | +public void fact() |
| 74 | + |
| 75 | +{ |
| 76 | + |
| 77 | +Console.WriteLine("Enter the number: "); int n = int.Parse(Console.ReadLine()); |
| 78 | + |
| 79 | +int f = 1 |
| 80 | + |
| 81 | +for (int i = 1 i <= n i++) |
| 82 | + |
| 83 | +{ f ^ * =i; |
| 84 | + |
| 85 | +} Console.WriteLine(f); |
| 86 | + |
| 87 | +} public void moneyconversion() |
| 88 | + |
| 89 | +{ |
| 90 | + |
| 91 | +float euro = 90f pound 105, yen 0.57f, dollar = 83 ; Console.WriteLine("Enter the amount of money: "); |
| 92 | + |
| 93 | +float rup = float.Parse(Console.ReadLine()); Console.WriteLine(rup + "Rupees = "+(rup/euro)+"Euro"); Console.WriteLine(rup + "Rupees Console.WriteLine(rup + "Rupees = Console.WriteLine(rup + "Rupees = "+ (rup / pound) + "Euro"); + (rup / yen) + "Euro"); + (rup / dollar) + "Euro"); |
| 94 | + |
| 95 | +} public void quad() |
| 96 | + |
| 97 | +{ |
| 98 | + |
| 99 | +int a = 0 b = 0 c = 0; |
| 100 | + |
| 101 | +double root1 = 0d , root2 0d; |
| 102 | + |
| 103 | +Console.WriteLine("Enter the a,b,c values: "); |
| 104 | + |
| 105 | +a = int.Parse(Console.ReadLine()); b = int.Parse(Console.ReadLine()); |
| 106 | +c = int.Parse(Console.ReadLine()); |
| 107 | + |
| 108 | +Console.WriteLine("Equation is: "+ a +"x^2+ "+b+"x + "+c); |
| 109 | + |
| 110 | +double v Math.Sqrt((b * b) (4 * a * c)); |
| 111 | + |
| 112 | +Console.WriteLine(v); |
| 113 | + |
| 114 | +root1=(-b+v)/(2*a); |
| 115 | + |
| 116 | +root2=(-b - v) /(2*a); |
| 117 | + |
| 118 | +if (root1 == root2) |
| 119 | + |
| 120 | +{ Console.WriteLine("roots are equal:"); |
| 121 | + |
| 122 | +} |
| 123 | + |
| 124 | +Console.WriteLine("roots are: "+root1+" and "+root2); |
| 125 | + |
| 126 | +} public static void Main() |
| 127 | + |
| 128 | +{ |
| 129 | + |
| 130 | +Class1 ob new Class1(); |
| 131 | + |
| 132 | +Console.WriteLine("fibonacci series: "); |
| 133 | + |
| 134 | +ob.fibo(); |
| 135 | + |
| 136 | +Console.WriteLine("\n\nCheck for prime numbers: "); |
| 137 | + |
| 138 | +ob.testprime(); |
| 139 | + |
| 140 | +Console.WriteLine("\n\nCheck for vowels: "); |
| 141 | + |
| 142 | +ob.vowel(); |
| 143 | + |
| 144 | +Console.WriteLine("\n\nforeach loop: "); |
| 145 | + |
| 146 | +ob.useforeach(); |
| 147 | + |
| 148 | +Console.WriteLine("\n\nreverse and sum: "); |
| 149 | + |
| 150 | +ob.reverseAndSum(); |
| 151 | + |
| 152 | +Console.WriteLine("\n\nfactorial: "); |
| 153 | + |
| 154 | +ob.fact(); |
| 155 | + |
| 156 | +Console.WriteLine("\n\nmoney conversion: "); |
| 157 | + |
| 158 | +ob.moneyconversion(); |
| 159 | + |
| 160 | +Console.WriteLine("\n\nquadratic equation: ");ob.quad(); |
| 161 | + |
| 162 | +Console.ReadKey(); |
| 163 | + |
| 164 | +} |
| 165 | + |
| 166 | +} } |
0 commit comments