Given a variable age, if the value is greater than 42 display "You are old", otherwise display "You are young"
java
if (age > 42) { System.out.println("You are old"); } else { System.out.println("You are young"); }
public class Solution47 { public static void main(String[] args) { if (age > 42) { System.out.println("You are old"); } else { System.out.println("You are young"); } } }
java
System.out.println("You are " + ((age>42)?"old":"young"));
public class Solution48 { public static void main(String[] args) { System.out.println("You are " + ((age>42)?"old":"young")); } }
cppC++/CLI .NET 2.0
if (age > 42) Console::WriteLine("You are old"); else Console::WriteLine("You are young");
using namespace System;
int main() { int age = 42;
if (age > 42) Console::WriteLine("You are old"); else Console::WriteLine("You are young"); }
cppC++/CLI .NET 2.0
Console::WriteLine("You are {0}", (age > 42 ? "old" : "young"));