w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Print the result of print the result of the specified operations


C# Sharp Basic: Exercise-4 with Solution

Write a C# Sharp program to print the result of the specified operations.

C# Sharp: Working with Arithmetic Expression

C# sharp Exercises: how arithmetic expression works

Sample Solution:

C# Sharp Code:

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
    }
}

Sample Output:

23                                                                                                            
5                                                                                                             
12                                                                                                            
3

Flowchart:

Flowchart: C# Sharp Exercises - Print the result of print the result of the specified operations

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# Sharp program to print the result of dividing two numbers.
Next: Write a C# Sharp program to swap two numbers.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming