Write a C# program to print hello world and your name in a separate line. (Beginners program of C#)
Write a C# program to print hello
world and your name in a separate line.
: Sample solution:
Public class helloWorld
{
public static void Main()
{
System.Console.WriteLine("Hello World");
System.Console.WriteLine("Ajaya Bista");
}
}
Sample Output
Hello World
Ajaya Bista
System.Console.WriteLine method writes the specified data, followed by the current line terminator, to the standard output stream.
Details of Write Lines() Method:
Methods |
Description |
WriteLine() |
This method writes the current line terminator to the standard output stream. |
WriteLine(Boolean) |
This method writes the text representation of the specified Boolean value, followed by the current line terminator, to the standard output stream. |
WriteLine(Char) |
This method writes the specified Unicode character, followed by the current line terminator, value to the standard output stream. |
WriteLine(Char[]) |
This method writes the specified array of Unicode characters, followed by the current line terminator, to the standard output stream. |
Int32) Int32, WriteLine(Char[], |
This method writes the specified subarray of Unicode characters, followed by the current line terminator, to the standard output stream. |
WriteLine(Decimal) |
This method writes the text representation of the specified Decimal value, followed by the current line terminator, to the standard output stream. |
WriteLine(Double) |
This method writes the text representation of the specified double-precision floating-point value, followed by the current line terminator, to the standard output stream. |
WriteLine(Int32) |
This method writes the text representation of the specified 32-bit signed integer value, followed by the current line terminator, to the standard output stream. |
WriteLine(Int64) |
This method writes the text representation of the specified 64-bit signed integer value, followed by the current line terminator, to the standard output stream. |
WriteLine(Object) |
This method writes the text representation of the specified object, followed by the current line terminator, to the standard output stream. |
WriteLine(Single) |
This method writes the text representation of the specified single-precision floating-point value, followed by the current line terminator, to the standard output stream. |
WriteLine(String) |
This method writes the specified string value, followed by the current line terminator, to the standard output stream. |
WriteLine(String,Object) |
This method writes the text representation of the specified object, followed by the current line terminator, to the standard output stream using the specified format information. |
WriteLine(String,Object,Object) |
This method writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information. |
WriteLine(String,Object,Object,Object) |
This method writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information. |
WriteLine(String,Object,Object,Object,Object) |
This method writes the text representation of the specified objects and variable-length parameter list, followed by the current line terminator, to the standard output stream using the specified format information. |
WriteLine(String,Object[]) |
This method writes the text representation of the specified array of objects, followed by the current line terminator, to the standard output stream using the specified format information. |
WriteLine(UInt32) |
This method writes the text representation of the specified 32-bit unsigned integer value, followed by the current line terminator, to the standard output stream. |
WriteLine(UInt64) |
This method writes the text representation of the specified 64-bit unsigned integer value, followed by the current line terminator, to the standard output stream. |
For More details Goto Source page: https://www.w3resource.com/csharp-exercises
write a C# program to enter any two number and display its addition result..
ReplyDeleteusing System;
public class Program
{
public static void Main()
{
int num1 , num2 , num3;
Console.WriteLine("Enter the number one:");
num1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number two:");
num2=Convert.ToInt32(Console.ReadLine());
num3=num1 + num2;
Console.WriteLine("Result is:"+ num3);
}
}
Write a c# program to check entered number is equal or not....
ReplyDeleteusing System;
public class Program
{
public static void Main()
{
int num1 , num2;
Console.WriteLine("Enter the number one:");
num1=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number two:");
num2=Convert.ToInt32(Console.ReadLine());
if(num1== num2)
{
Console.Write("Equal");
}
else
{
Console.Write("Not equal");
}
}
}
using System;
ReplyDeletepublic class Exercise1
{
public static void Main()
{
int int1,int2;
Console.Write("\n\n");
Console.Write("Check whether two integers are equal or not:\n");
Console.Write("-------------------------------------------");
Console.Write("\n\n");
Console.Write("Input 1st number: ");
int1= Convert.ToInt32(Console.ReadLine());
Console.Write("Input 2nd number: ");
int2= Convert.ToInt32(Console.ReadLine());
Console.Write("\n\n");
if (int1 == int2)
Console.WriteLine(" Both are equal.\n");
else
Console.WriteLine(" these number are not equal.\n");
}
}
Write a c# program to print average of two numbers....
ReplyDeleteusing System;
public class Exercise1
{
public static void Main()
{
int Int1,int2, avg;
Console.Write("\n\n");
Console.Write("Average of Two number:\n");
Console.Write("-------------------------------------------");
Console.Write("\n\n");
Console.Write("Input 1st number: ");
Int1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input 2nd number: ");
int2 = Convert.ToInt32(Console.ReadLine());
avg= (Int1 + int2)/ 2;
Console.WriteLine(" The average of two number is.\n"+avg);
}
}