Computer Science, asked by umeshmehar682, 1 month ago

write a program to check whether the number 20 is an even number or odd number using trenary operator​

Answers

Answered by anzilafatima
1

Answer:

int main()

{

int n;

cout << "Enter an integer: ";

cin >> n;

if ( n % 2 == 0)

cout << n << " is even.";

else

cout << n << " is odd.";

return 0;

}

Explanation:

set the value of n=20 at the end of program .

or initialize the value in the beginning like

int n=20;

Answered by SaitamaOPM
0

Answer:

public class ti {

   public static void main(String[]args){

       String a = " the Nunber is Even";

       String b = " the Number is Odd ";

       String A = (20%2==0)? a : b;

       System.out.println(A);

   }

}

Explanation:

Similar questions