1. Swaping of two numbers without using arithmetic operators.
using System; class swap { public static void Main() { int a,b; Console.WriteLine("Enter first value"); string n1=Console.ReadLine(); a=int.Parse(n1); Console.WriteLine("Enter second value"); string n2=Console.ReadLine(); b=int.Parse(n2); Console.WriteLine("a = "+a+" b = "+b); a=a^b; b=a^b; a=a^b; Console.WriteLine("Value Swaped "); Console.WriteLine("a = "+a+" b = "+b); } }
Deepak kumar koshta
2.
Adding two numbers without using arithmetic operators.
using System; class add { public static void Main() { int a,b,x,y; Console.WriteLine("Enter Two Numbers_ "); string n1=Console.ReadLine(); x=int.Parse(n1); string n2=Console.ReadLine(); y=int.Parse(n2); do { a = x & y; b = x ^ y; x = a << 1; y = b; } while (a!=0); Console.WriteLine("Addition = "+y); } }
Deepak kumar koshta
3.
program for encryption and decryption of a string by using a key.
4. Write a program to find the highest number at given place in the array without sorting. using System; class Highest { static void Main() { int value=0,i,j,k=0; Console.WriteLine("Enter Size of Array"); int asize=int.Parse(Console.ReadLine()); int[] amax=new int[size]; Console.WriteLine("Input values in the array"); for(i=0;i<size;i++) { int a=int.Parse(Console.ReadLine()); amax[i]=a; } Console.WriteLine("Current Array is "); for(i=0;i<asize;i++) { Console.WriteLine(amax[i]); } Console.WriteLine("Degree of higest"); int b=int.Parse(Console.ReadLine()); if(b<=size/2) { for(j=0;j<b;j++) { value=amax[0]; for(i=0;i<size;i++) { if(value<=amax[i]) { value=amax[i]; k=i; } } for(int l=0;l<asize;l++) { if(amax[l]==value) { amax[k]=0; } } }Console.WriteLine("Highest value at position "+b+" = "+value); } else { Console.WriteLine("Enter value half of array size"); } } }