You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
649 B
C#

/*
Write a C# Sharp program to print the result of the specified operations.
Test data:
• -1 + 4 * 6
• ( 35+ 5 ) % 7
• 14 + -4 * 6 / 11
• 2 + 15 / 6 * 1 - 7 % 2
Expected Output:
23
5
12
3
*/
public class Exercise4
{
public static void Main()
{
System.Console.WriteLine(-1+4*6);
//-1 + 24 = 23
System.Console.WriteLine((35+5)%7);
//40 % 7 = 5 (remainder of 40/7)
System.Console.WriteLine(14+-4*6/11);
//14 - (24/11)= 14 - 2 = 12
System.Console.WriteLine(2+15/6*1-7%2);
//2 + (15/6) - remainder of (7/2) = 2 + 2 - 1 = 4 - 1 = 3
}
}