Answer to Question #181087 in C# for noor

Question #181087

 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]


1
Expert's answer
2021-04-13T19:25:13-0400
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");                
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS