programming-examples/c-sharp/Basic/C# Sharp program to print the result of the specified operations.cs

32 lines
649 B
C#
Raw Normal View History

2019-11-18 14:44:36 +01:00
/*
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
}
}