If the above code is entered properly and the program is executed successfully, following output will be displayed. Finally the console.write function is used to display the number to the console.The variable is then assigned a value of 30. The Int32 data type is specified to declare an Integer variable called num.We will then assign an Integer value to the variable and then display it accordingly. In our example, we will define an Int32 variable called num. Below is an example of how this datatype can be used. In C#, the datatype is denoted by the Int32 keyword. In this case, the numbers are whole numbers like 10, 20 or 30. 1) IntegerĪn Integer data types are used to work with numbers. For each example, we will modify just the main function in our Program.cs file. Let’s explore the basic data types available in C#. These data types are used to build values which are used within an application. Data Type Bytes Occupied in RAM Value Range The range of values referred unsigned char 1 byte 0 to 2 8-1 0 to 255 short int 1 byte -2 7 to 2 7-1 -128 to 127 unsigned short int 1 byte 0 to 2 8-1 0 to 255 unsigned int 2 bytes 0 to 2 16-1 0 to 65535 long int 4 bytes -2 31 to 2 31-1 -2,147,483,648 to 2,147,483,647 unsigned long int 4 bytes 0 to 2 32-1 0 to 4,294,967,295 long double 10 bytes -2 79 to 2 79-1 3.4e-4932 to 1.The C# language comes with a set of Basic data types. A double-precision number is used to represent 12 decimal digits like 3.412587632156 or 4.52145342148e12.Ĭ language has additional data types along with the basic data types to enable the users to declare a variable in an appropriate type to improve the program execution speed and to refer to the largest and smallest numbers possible in programming for science and engineering applications. It can hold a real number in double precision. double:- This also refers to floating-point or real number.It is used to represent a real number like 3.174813 or 4.52e6 with six decimal digits in decimal or exponential form. float:- This refers to a floating-point or real number.This is used to represent the signed or unsigned whole number within a specific range. int:- This refers to an integer value.In fact, the character in c is associated with integers to refer to a letter/symbol as per ASCII( American Standard Code for Information Interchange) that has assigned integer value for all letters/symbols used in programming. Read also, Generation of Computers with their characteristics The four basic data types in C language are defined as follows (Its decimal equivalent can be calculated by using a calculator but in the case of double, the calculator gives inaccurate answers since they are designed only to handle a small range of values. So, the range is expressed as -2 to the power 15 to 2 to the power 15-1. 16 bits from this 1 bit is taken for sign (- or +). Note that the value range is calculated from the number of bits occupied by the data type. They are given below along with the number of bytes occupied by them in the computer memory. There are four basic data types in C language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |