Literals and Constants in C# Programming

Constants In any programing language including C#, constants are values which are fixed and cannot be changed anytime during program execution. They can be of any data type. We can use const to make a variable constant. Example of some constants are:

C Program to Display the Day Name According To a Number Entered

This C program displays the name of the day by asking the user to input a number. For example, if the user enters 1 then “SUNDAY” is displayed, if the user enters 2 then “MONDAY” is displayed and so on. The C program code to display the day name according to number you entered are as follows.

C Program to Check Whether a Year is Leap Year or Not

A year that has 366 days is called a leap year. A year can be checked whether a year is leap year or not by dividing the year by 4, 100 and 400. If a number is divisible by 4 but not by 100 then, it is a leap year. Also, if a number is divisible by 4, 100 and 400 then it is a leap year. Otherwise the year is not a leap year.

Variables in C# programming

In any programing language including C#, variables are the memory space in computer where data can be stored. A variable in C# programming is defined by three main features: name, type and value (optional). Let us take an example: int var = 1; In above example, var is the name of variable, int is the type of variable var and 1 is the value stored in memory location.

Type Conversion in C# Programming

Type Conversion is process of converting one data type into another data type. This help us choose most appropriate type for the variable. It is also known as type casting. It can be done in two ways:

Data Types in C# Programming

Data type is a categorization of variable to define what type of data can be stored in that variable. In C#, declaration of a data type is compulsory. This helps compiler know what type of data will be stored in that variable. These data types can be categorized in following three types: