1 Conditional
1 Conditional
using System;
class Program
{
static void Main()
{
Console.Write("Enter a number: ");
int number = Convert.ToInt32(Console.ReadLine());
if (number > 0)
Console.WriteLine("Positive");
else if (number < 0)
Console.WriteLine("Negative");
else
Console.WriteLine("Zero");
}
}
using System;
class Program
{
static void Main()
{
Console.Write("Enter a number: ");
int number = Convert.ToInt32(Console.ReadLine());
if (number % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
}
}
using System;
class Program
{
static void Main()
{
Console.Write("Enter first number: ");
int a = Convert.ToInt32(Console.ReadLine());
if (a > b)
Console.WriteLine($"{a} is larger");
else
Console.WriteLine($"{b} is larger");
}
}
using System;
class Program
{
static void Main()
{
Console.Write("Enter a character: ");
char ch = Convert.ToChar(Console.ReadLine().ToLower());
using System;
class Program
{
static void Main()
{
Console.Write("Enter your age: ");
int age = Convert.ToInt32(Console.ReadLine());
using System;
class Program
{
static void Main()
{
Console.Write("Enter a number: ");
int number = Convert.ToInt32(Console.ReadLine());
using System;
class Program
{
static void Main()
{
Console.Write("Enter first number: ");
int a = Convert.ToInt32(Console.ReadLine());
using System;
class Program
{
static void Main()
{
Console.Write("Enter your marks: ");
int marks = Convert.ToInt32(Console.ReadLine());
using System;
class Program
{
static void Main()
{
Console.Write("Enter a year: ");
int year = Convert.ToInt32(Console.ReadLine());
using System;
class Program
{
static void Main()
{
Console.Write("Enter first number: ");
double num1 = Convert.ToDouble(Console.ReadLine());
switch (op)
{
case '+':
Console.WriteLine("Result: " + (num1 + num2));
break;
case '-':
Console.WriteLine("Result: " + (num1 - num2));
break;
case '*':
Console.WriteLine("Result: " + (num1 * num2));
break;
case '/':
if (num2 != 0)
Console.WriteLine("Result: " + (num1 / num2));
else
Console.WriteLine("Cannot divide by zero");
break;
default:
Console.WriteLine("Invalid operator");
break;
}
}
}