Skip to content

Instantly share code, notes, and snippets.

@IvanNikolov
Created October 15, 2014 10:49
Show Gist options
  • Save IvanNikolov/c3e44de484093861b17b to your computer and use it in GitHub Desktop.
Save IvanNikolov/c3e44de484093861b17b to your computer and use it in GitHub Desktop.
using System;
//Write a program that shows the sign (+, - or 0)
//of the product of three real numbers,
//without calculating it. Use a sequence of if operators. Examples:
//a b c result
//5 2 2 +
//-2 -2 1 +
//-2 4 3 -
//0 -2.5 4 0
class MultiplicationSign
{
static void Main()
{
double a = double.Parse(Console.ReadLine());
double b = double.Parse(Console.ReadLine());
double c = double.Parse(Console.ReadLine());
if (((a < 0 && b < 0) && (c > 0) || (a > 0 && b > 0) && (c > 0)))
{
Console.WriteLine("+");
}
else if (a == 0)
{
Console.WriteLine("0");
}
else
{
Console.WriteLine("-");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment