Answers in C#
1.
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(Console.ReadLine());
}
2.
[STAThread]
static void Main(string[] args)
{
int a;
int b;
int result;
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
result = a + b;
Console.WriteLine(result.ToString());
result = a * b;
Console.WriteLine(result.ToString());
result = a / b;
Console.WriteLine(result.ToString());
result = a - b;
Console.WriteLine(result.ToString());
}
3.
[STAThread]
static void Main(string[] args)
{
int a;
int b;
int dummy;
a = Convert.ToInt32(Console.ReadLine());
b = Convert,ToInt32(Console.ReadLine());
dummy = a;
a = b;
b = dummy;
Console.WriteLine(a.ToString());
Console.WriteLine(b.ToString());
}
4.
[STAThread]
static void Main(string[] args)
{
int a;
int b;
int result;
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
result = a*b;
Console.WriteLine(result.ToString());
result = a + a + b + b;
Console.WriteLine(result.ToString());
}
Easy.
|