Variable:
- A variable is a named memory location that can be assigned a value.
- The value of variable can be changed during the execution of the program.
Program using two variable:
using System; // using is the variable and Sysytem is the Namespace
class program2 // program2 is the name the class
{
public static void Main()
{
int a; // This declares the variable1
int b; // This declares the variable2
a=50; // assign 50 to a
Console.WriteLine("The value of a:"+a); //the + sign causes the value of a to be displayed.
b=a*2; // assigned a multiplied by 2 to b
Console.Write("The value of b:"); //write() is to display the strings it contains and the next output will be generated in sameline.
Console.Writeline(b);
}
}
output:
The value of a: 50
The value of b: 100
0 comments for this post