Q:

Write a C# program to check two given integers and return true if one is negative and one is positive

0

Write a C# program to check two given integers and return true if one is negative and one is positive

Sample Output:

Input first integer:                                                   
-5                                                                     
Input second integer:                                                  
25                                                                     
Check if one is negative and one is positive:                          
True

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;

public class Exercise18 {
  static void Main(string[] args)
        {
           Console.WriteLine("\nInput first integer:");  
           int x = Convert.ToInt32(Console.ReadLine());
           Console.WriteLine("Input second integer:");  
           int y = Convert.ToInt32(Console.ReadLine());
           Console.WriteLine("Check if one is negative and one is positive:");
           Console.WriteLine((x < 0 && y > 0) || (x > 0 && y < 0));
        }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now