C# Sharp Exercises: Print three numbers(x, y, z) in (x+y)·z and x·y + y·z format
C# Sharp Basic: Exercise-10 with Solution
Write a C# Sharp program to that takes three numbers(x,y,z) as input and print the output of (x+y)·z and x·y + y·z.
Sample Solution:
C# Sharp Code:
using System;
public class Exercise10
{
public static void Main()
{
int number1, number2, number3;
Console.Write("Enter first number - ");
number1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter second number - ");
number2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter third number - ");
number3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Result of specified numbers {0}, {1} and {2}, (x+y)·z is {3} and x·y + y·z is {4}\n\n",
number1, number2, number3, ((number1+number2)*number3), (number1*number2+number2*number3));
}
}
Sample Output:
Enter first number - 4 Enter second number - 6 Enter third number - 2 Result of specified numbers 4, 6 and 2, (x+y)·z is 20 and x·y + y·z is 36
Flowchart:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program that takes four numbers as input to calculate and print the average.
Next: Write a C# Sharp program that takes an age (for example 20) as input and prints something as "You look older than 20.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework