When we multiply different numbers they come with different sign such as (Plus (+), Negative (-)) suppose : (-2) * (+2) = -4, your task is to write such an application that show(Display) the sign of four real number after multiplication by using sequence of if operator.[Note you can’t calculate it]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter first number: ");
double R1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter second number: ");
double R2 = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter third number: ");
double R3 = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter fourh number: ");
double R4 = Convert.ToDouble(Console.ReadLine());
if (R1 == 0 || R2 == 0 || R3 == 0 || R4 == 0)
Console.WriteLine("There will be zero");
else if (R1 > 0 && R2 > 0 && R3 > 0 && R4 > 0)
Console.WriteLine("There will be positive result");
else if (R1 < 0 && R2 < 0 && R3 < 0 && R4 < 0)
Console.WriteLine("There will be positive result");
else if (R1 < 0 && R2 < 0 && R3 > 0 && R4 > 0) //34
Console.WriteLine("There will be positive result");
else if (R1 < 0 && R2 > 0 && R3 > 0 && R4 < 0) //23
Console.WriteLine("There will be positive result");
else if (R1 > 0 && R2 > 0 && R3 < 0 && R4 < 0) //12
Console.WriteLine("There will be positive result");
else if (R1 > 0 && R2 < 0 && R3 > 0 && R4 < 0) //13
Console.WriteLine("There will be positive result");
else if (R1 < 0 && R2 > 0 && R3 < 0 && R4 > 0) //24
Console.WriteLine("There will be positive result");
else if (R1 > 0 && R2 < 0 && R3 < 0 && R4 > 0) //14
Console.WriteLine("There will be positive result");
else
Console.WriteLine("There will be negative result");
}
}
}
Comments
Leave a comment