Que:- you can use any valid Boolean expression for the condition. You can use logical operators such as &&, &, ||, | and ! to make compound conditions. The following code shows examples???
A
Ans:- using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
bool result=true;
if (!result)
{
Console.WriteLine("false");
}
else
{
Console.WriteLine("true");
}
//and
int m = 9;
int n = 7;
int p = 5;
if (m > n && m > p)
{
Console.WriteLine("m is greater than n and p");
}
if (m > n && !(p > m))
{
Console.WriteLine("m is greater than n and p");
}
if (m > n || m > p)
{
Console.WriteLine("greater");
}
m = 4;
if (!(m >= n || m >= p))
{
Console.WriteLine("smaller");
}
Console.ReadKey();
}
}
}
A
Ans:- using System;
using System.Collections.Generic;
using System.Text;
namespace codeforevenorodd
{
class Program
{
static void Main(string[] args)
{
bool result=true;
if (!result)
{
Console.WriteLine("false");
}
else
{
Console.WriteLine("true");
}
//and
int m = 9;
int n = 7;
int p = 5;
if (m > n && m > p)
{
Console.WriteLine("m is greater than n and p");
}
if (m > n && !(p > m))
{
Console.WriteLine("m is greater than n and p");
}
if (m > n || m > p)
{
Console.WriteLine("greater");
}
m = 4;
if (!(m >= n || m >= p))
{
Console.WriteLine("smaller");
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment