Skip to main content

Posts

Showing posts with the label C#

Factorial Of A Number With Static Function And Variable (C#)

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication10 {     class Program     {        static int num;        static long factorial = 1;        static void facto()         {                Console.WriteLine("Enter the number limit should be less than 20");             num = Convert.ToInt16(Console.ReadLine());             if (num > 20)             {                 Console.WriteLine("You exceed the limit ");             }             else             {                 if (num < 0)     ...

Prime Numbers In Range the User Want (C#)

using System; using System.Collections.Generic; class Program {      public void prime(int num)     {               Boolean isPrime = true;         Console.WriteLine("the prime number between 1-{0} is: ",num);         for (int i = 0; i <= num; i++)         {             for(int j=2;j<=num;j++)                 if (i != j && i % j == 0)                 {                     isPrime = false;                     break;                 }             if (isPrime == true)             { Console.WriteLine("{0}", i); }     ...

Division Of Greater Than First Number (C#)

using System; using System.Collections.Generic; class Program {     static void Main()     {         int a, b,result; Console.WriteLine("www.promohack.blogspot.com");         Console.WriteLine("Enter the first number");         a =Convert.ToInt16( Console.ReadLine());         Console.WriteLine("Enter the second number");         b = Convert.ToInt16(Console.ReadLine());         if (b == 0||b>a)         {             Console.WriteLine("Your second number should not be zero or greater than first number");         }         else         {             result = a / b;             Console.WriteLine("Your result is "+result);         } ...

Division Of Two Numbers In C#

using System; using System.Collections.Generic; class Program {     static void Main()     { Console.WriteLine("www.promohack.blogspot.com");//two print         int a, b,result;//declaring variables         Console.WriteLine("Enter the first number");         a =Convert.ToInt16( Console.ReadLine());//accept value from user         Console.WriteLine("Enter the second number");         b = Convert.ToInt16(Console.ReadLine());         if (b == 0)//condition         {             Console.WriteLine("Your second number should not be zero");         }         else         {             result = a / b;             Console.WriteLine("Your result is "+result); ...