This C# program defines two integer variables, a and b, assigns them values of 2 and 5 respectively. It then prints the values of a and b to the console. It uses a ternary operator to check if a is greater than b, and assigns the greater value to x, then prints x to display the larger of a and b.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
73 views1 page
C# Program to Find Maximum Value
This C# program defines two integer variables, a and b, assigns them values of 2 and 5 respectively. It then prints the values of a and b to the console. It uses a ternary operator to check if a is greater than b, and assigns the greater value to x, then prints x to display the larger of a and b.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
class rt1 { public static void Main() { int a=2; int b=5; int x; System.Console.WriteLine("a="+a); System.Console.WriteLine("b="+b); x=(a>b)?a:b; System.Console.