Here Are The C#-WPS Office
Here Are The C#-WPS Office
```csharp
using System;
namespace OddOrEven
class Program
if (num % 2 == 0)
else
}
}
```
2. Obtain two numbers from the keyboard, and determine and display which (if either) is the larger of
the two numbers:
```csharp
using System;
namespace LargerNumber
class Program
{
Console.WriteLine("Second number is larger");
else
```
3. Receive 3 numbers and display them in ascending order from smallest to largest:
```csharp
using System;
namespace AscendingOrder
class Program
Array.Sort(numbers);
Console.WriteLine(num);
```
```csharp
using System;
namespace SumOfNumbers
class Program
{
int sum = 0;
sum += i;
```
5. Add the even numbers between 0 and any positive integer number given by the user:
```csharp
using System;
namespace SumOfEvenNumbers
class Program
int sum = 0;
if (i % 2 == 0)
sum += i;
```
```csharp
using System;
namespace AverageOfTwoNumbers
class Program
{
static void Main(string[] args)
```
7. Find the average, maximum, minimum, and sum of three numbers given by the user:
```csharp
using System;
namespace AverageMinMaxSumOfThreeNumbers
class Program
{
Console.Write("Enter first number: ");
```
8. Find the area of a circle where the radius is provided by the user:
```csharp
using System;
namespace AreaOfCircle
class Program
```
```csharp
using System;
namespace SwapVariablesUsingThirdVariable
class Program
{
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
int temp = a;
a = b;
b = temp;
```
10. Swap the contents of two variables without using a third variable:
```csharp
using System;
namespace SwapVariablesWithoutThirdVariable
{
class Program
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
// a=a+b;
// b=a-b;
// a=a-b;
// OR
a=a+b-(b=a);
// OR
(a,b)=(b,a);
// OR
b=a+a-(a=b);
//OR
(a=a+(b=a),b=b-a);
//OR
var t=a;a=b;b=t;
//OR
var t=a+a-(b=a);a=t/2;b=t/2+0.5m;
//OR
var t=(a,b);a=t.b;b=t.a;
//OR
//OR
var t=(a,a+b);a=t.b;b=t.a;
a=b+(b=a);
//OR
var t=(a+a);a=b;b=t.a;
```
11. Read an integer value from the keyboard and display a message indicating if this number is odd or
even:
```csharp
using System;
namespace OddOrEvenNumber
{
class Program
bool flag=true;
while(flag)
try
try
if(flag)
flag=false;
else
flag=true;
}
catch
try
try
flag=false;
catch
}
}
catch
try
try
flag=true;
catch
}
catch
int n=Convert.ToInt32(Console.ReadLine());
if(n%2==0)
Console.WriteLine(n+" is even");
else
Console.WriteLine(n+" is odd");
}
}
12. Read 10 integers from the keyboard in the range 0 - 100, and count how many of them are larger
than 50:
```csharp
using System;
namespace CountNumbersGreaterThan50
class Program
int count=0;
for(int i=0;i<10;i++)
try
try
bool flag=true;
while(flag)
try
catch
catch
catch
try
bool flag=true;
while(flag)
try
{
flag=false;
catch
catch
}
Console.Write($"Enter integer {i+1}:");
int n=Convert.ToInt32(Console.ReadLine());
if(n>50)
count++;
13. Take an integer from the user and display the factorial of that number:
```csharp