Skip to main content

Posts

Program in C sharp # to merge two numbers and findest nearest vowel to a inputted character ( question from bca previous year question paper very important )

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace npgc {    static  class math     {         public static string nearest(char ch)         {             int i=0;             int j=(int)ch;             string ret="";             char[] arr = {'a','e','i','o','u'};             for (i=0;i< arr.Length - 1; i++)             {                 int tmp=(int)(arr[i]);              int tmp2=(int)arr[i+1];              if (j < tmp2)              {                  int a = j - tmp;     ...

Static Class in C sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication14 {public static class math  {      public static int big(int a, int b)     {         if (a > b)             return a;         else             return b;      }      public static int pow(int a, int b)      {int i=0,pow=1;      for (i = 0; i < b; i++)          pow = pow * a;      return pow;      }   }     class Program     {         static void Main(string[] args)         {             Console.WriteLine("Big is :"+math.big(100,102));             Console.WriteLine("Power is: "...

Sealed Class in C sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication13 {     sealed class x     {       public   int x2, y2, z2;       public x()       {           x2 = 123;           y2 = 456;           z2 = 789;       }         public void display()         {             Console.WriteLine("Display 1");         }         public void print()         { Console.WriteLine("Print 1"); }             }                 class Program     {         static void Main(string[] args)         {        ...

Partial class in c sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication12 {     partial class x     {         public void display()         {             Console.WriteLine("Display 1");         }         public void print()         { Console.WriteLine("Print 1"); }     }     partial class x     {         public void display2()         { Console.WriteLine("Display 2"); }         public void print2()         { Console.WriteLine("Print 2"); }     }     class Program     {         static void Main(string[] args)         {             x ob = new x();   ...

Playfair Cipher in C Sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; //WHile making this program we assume that there is no j in the english alphabet // while searching we consider both i and j as same namespace ConsoleApplication5 {     class Program     {         static int rs=0, cs = 0;         static string encrypt="";         static char[,] arr = new char[5, 5];         static void Main(string[] args)         {                         string key="",text="",text2="";             int i,l,r=0,c=-1;                     Console.WriteLine("Enter a key");             key=Console.ReadLine();             key = key.Trim();     ...

Abstract Class in C Sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication10 {      public abstract class abc     {         int i;       public  abc(int y)         {             i = y;             display(i);         }       public abstract void display(int x);           }     class Program:abc     {         public Program():base(1000)         {         }         static void Main(string[] args)         {            Program ab= new Program();             Console.ReadKey();         }         public over...

Interface in c sharp #

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication11 {     interface abc {      void display();     }     class Program:abc     {         static void Main(string[] args)         {             Program ab = new Program();             ab.display();             Console.ReadKey();         }       public void display()         {             Console.WriteLine("Hello world");         }     } }