What Is Variables & Datatypes In C Language Btech BCA Notes
Variables & Datatypes In C Language |
We are talking about variables and datatypes in C. Variables and Datatypes are very important in c program. when we talking about store information data in memory. Then C language provides a variety of datatypes these data types we use according to our requirements.
Before you read this article May you also like our previous posts:- Beginner our view on C programming Language and Structure Of C Language Program
Variables in C Language
Whenever an Application is executed, it gets space in the primary memory(RAM). The amount of space allocated to a program depends on the amount of data on which operations is to be perform.
All the data items on which operation is to be performed are saved in the primary memory through out the lifetime of the processing.
Variable in C |
We can create any number of variables in a given program. Each variable can store one value. Each variable has a unique name.
Rules for naming in a Variables
- Variable name is a case sensitive(a≠A).
- A variable name can contain alphabets, numbers and underscore. No other special symbol can be used.
- Variable name can start either with an alphabet or with an underscore. It can never start with a number.
- A variable name must contain at least one Underscore or an alphabet.
- Maximum length of a variable name is 38.
Datatypes in C Language
Whenever an application is executed, The data on which that application works is saved in the memory blocks called variables. A variable is allocated space inside the space allocated to he program running in the memory.
Datatype in C Language |
Definition:- Data type is an attribute of a variable. A datatype in a programming language, is a classification which what type of value a variable can store and what type of mathematical operation, logical operation, Relational operation can be performed to a variable without causing an error.
Types of Datatypes in C |
Integer Types
Name | size | range |
---|---|---|
Shot | 1 | -128 to 127 |
Int | 2 | -32768 to 32767 |
Long | 4 | -2147483648 to 2147483647 |
Floating Point Types
Name | size | range |
---|---|---|
Float | 4 | -3.4*1038 to 3.4*1038 |
Double | 8 | -1.79*10308 to 1.79*10308 |
Long Double | 10 | -1.1*104932 to 1.1*104932 |
Floating point types provide the facility to represent decimal number. C-lang, Their are three types namely float, Double, Long double. Each of data type have different precision value.
Name | Precision |
---|---|
Float | 6 |
Double | 15 |
Long Double | 18 |
Data type of Character type
In C Language, We are provided with a data type named char which is used to store a character (an alphabet, Special symbol, Single digit number). Char datatype is used to store a string.
Name | Size |
---|---|
Char | 1 byte |
Whenever a variable is created, the data type of variable needs to be specified at the time of creation. In a given program, We can create any number of variables. They can either be of same type or different type.
- creating 'n' variable of same type:
datatype var name 1, var name 2, ........... var name n;
Eg. float a,b,c,d,e;
- Creating variable of different data type:
datatype 1 var name 1, var name 2, ........... var name n;
datatype 2 var name 1, var name 2, ........... var name n;
Eg. int a,b,c;
float x,y;
long d;
User Defined type
User defined type |
We can create user defined data types either by using structure or by a using union.
Derived data type
derived data type |
We will going on series of C Programming language of all topics. So, you can follow us for more updates.
Comments
Post a Comment