Write a C# Sharp program to print Hello and your name in a separate line.
public class Exercise1
System.Console.WriteLine("Hello");
System.Console.WriteLine("Alexandra Abramov!");
Hello
Alexandra Abramov!
Write a C# Sharp program to print the sum of two numbers.
public class Exercise2
{
public static void Main()
{
System.Console.WriteLine(15+17);
}
}
Sample Output:
32
Sample Output:
6
Write a C# Sharp program to print the output of multiplication of three numbers
which will be entered by the use
using System;
public class Exercise6
{
public static void Main()
{
int num1, num2, num3;
Sample Output:
Input the first number to multiply: 2
Input the second number to multiply: 8
Input the third number to multiply: 5
Output: 2 x 8 x 5 = 80
using System;
Sample Output:
Enter a number: 10
Enter another number: 2
10 + 2 = 12
10 - 2 = 8
10 x 2 = 20
10 / 2 = 5
10 mod 2 = 0
using System;
int x;
int result;
Console.WriteLine("Enter a number:");
x = Convert.ToInt32(Console.ReadLine() );
result = x * 1;
Console.WriteLine("The table is : {0} x {1} = {2}", x, 1, result);
result = x * 2;
result = x * 3;
result = x * 4;
result = x * 5;
result = x * 6;
result = x * 7;
result = x * 8;
result = x * 9;
result = x * 10;
Sample Output:
Enter a number:
5
The table is : 5 x 1 = 5
: 5 x 2 = 10
: 5 x 3 = 15
: 5 x 4 = 20
: 5 x 5 = 25
: 5 x 6 = 30
: 5 x 7 = 35
: 5 x 8 = 40
: 5 x 9 = 45
: 5 x 10 = 50
using System;
using System.IO;
double number1,number2,number3,number4;
number1 = Convert.ToDouble(Console.ReadLine());
number2 = Convert.ToDouble(Console.ReadLine());
number3 = Convert.ToDouble(Console.ReadLine());
number4 = Convert.ToDouble(Console.ReadLine());
}
}
Sample Output:
Enter the First number: 17
Enter the Second number: 17
Enter the third number: 517
Enter the four number: 51
The average of 17, 17, 517, 51 is: 150.5
using System;
number1 = Convert.ToInt32(Console.ReadLine());
number2 = Convert.ToInt32(Console.ReadLine());
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",
}
}
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