This is a C# Program to check whether the entered number is even or odd.
Program/Source Code
Here if a given number is divisible by 2 with the remainder 0 then the number is an Even number. If the number is not divisible by 2 then that number will be an Odd number.
Program/Source Code
Here we write our first program of c# whether a number be a even number or odd number
using System;
public class OddEvenExample
{
public static void Main(string[] args)
{
int i;
Console.WriteLine( "Enter a number : ");
i = int.Parse(Console.ReadLine());
if(i % 2 == 0)
{
Console.WriteLine("Enter Number is an Even Number");
Console.Read();
}
else
{
Console.WriteLine("Enter Number is an Odd Number");
Console.Read();
}
}
}
This is a C# Program to add two numbers with the given values .
Program/Source Code | Add Two numbers in c#
Here if a given firstName and Lastname value and then placed these two value in result section which gives you the
actual result of the code .
Program/Source Code
Here we write our Second program of add two values firstname and second name in c#
using System;
public class AddTwoNumbers
{
public static void Main(string[] args)
{
int firstNumber = 20;
int secondNumber = 10;
int result;
result = firstNumber + secondNumber;
Console.WriteLine("{0} + {1} = {2}" , firstNumber , secondNumber , result);
}
}
5 + 10 = 15
This is a C# Program to add two numbers with the given values .
Program/Source Code | Get Input From User in c#
Here is the example of get input from the user in c# example user can use
Console.ReadLine();is used to get the user input through the keyboard in c# . In this example i have explain about about how user can take input from the user by keyboard.
Program/Source Code
Here we write our 3 program of Getting input from keyboard to user in c#
using System;
public class TakeInputExample
{
public static void Main(string[] args)
{
string userInput;
Console.WriteLine("Enter a input");
userInput = Console.ReadLine();
Console.WriteLine("you have entered {0}", userInput);
}
}