I. With Using Third variable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace swap
{
class Program
{
static void Main(string[] args)
{
int a, b, swap;
Console.WriteLine("Eneter 'a' value");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter 'b' value");
b = Convert.ToInt32(Console.ReadLine());
swap = a;
a = b;
b = swap;
Console.WriteLine("a== " + a + ", b== " + b);
Console.ReadLine();
}
}
}
II. without using third variable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace swap
{
class Program
{
static void Main(string[] args)
{
int a, b, swap;
Console.WriteLine("Eneter 'a' value");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter 'b' value");
b = Convert.ToInt32(Console.ReadLine());
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("a== " + a + ", b== " + b);
Console.ReadLine();
}
}
}
You r doing a great job plz can you tell me how to work with dataview also ?
ReplyDeleteya sure.. but give me some time..
Delete