Write a C# Sharp program that takes two numbers as input and returns true or false when both numbers are even or odd

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program that takes two numbers as input and returns true or false when both numbers are even or odd

Even Numbers between 1 to 100:

Calculating a Odd Numbers:

Odd Numbers between 1 to 100:

Sample Output:

Input First number: 4                                                                                         
Input Second number: 6                                                                                        
there're numbers bothEven

الأجوبة

using System;
public class Exercise10
{
  public static void Main()
  {
    int n1, n2;
    bool bothEven;
    Console.Write("Input First number: ");
    n1 = Convert.ToInt32(Console.ReadLine());
    Console.Write("Input Second number: ");
    n2 = Convert.ToInt32(Console.ReadLine());
    
    
    //bothEven = ((n1%2!=0) || (n1%2!=0))? false:true;
    bothEven = ((n1 % 2 == 0) 
        && (n2 % 2 ==0))? true : false;
        
      Console.WriteLine( bothEven ?
        "there're numbers bothEven" : 
        "there's a number odd");
  }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...