Skip to main content

What Is Variables & Datatypes In C Language Btech BCA Notes

 What Is Variables & Datatypes In C Language Btech BCA Notes


What Is Variables & Datatypes In C Language

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.

What is variables in C language?
Variable in C

These memory blocks can be accessed either through name or through address. The name given to the memory block is called variable name.

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

  1. Variable name is a case sensitive(a≠A).
  2. A variable name can contain alphabets, numbers and underscore. No other special symbol can be used.
  3. Variable name can start either with an alphabet or with an underscore. It can never start with a number.
  4. A variable name must contain at least one Underscore or an alphabet.
  5. 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.

what is Datatype in C Language?
Datatype in C Language

Variables can either contain same or different type of data. The memory requirement for storing different type of data is also different. The type of operation possible on different data items can either be same or different. All the above specified attributes are handled using a programming concept named datatype.

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.

How many types of datatypes in C?
Types of Datatypes in C

 Primitive data type are provided to us by the programming language. They have specific name and are used to work on some specific type of data.

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.

what is datatype and variable in program?
what is datatype and variable in program?

       example:-
  1. creating 'n' variable of same type:
          datatype var name 1, var name 2, ........... var name n;


          Eg.            float a,b,c,d,e;

  1. 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

In C- Programming Language, We can create custom datatypes to store different type of data in a single memory blocks under a single name. Such data types are called user defined data types.

We can create user defined data types either by using structure or by a using union.

Derived data type

derived data type

Derived types are data types which are created with the help of fundamental data types. They are used to store data of different type together or to a create a module of code.


We will going on series of C Programming language of all topics. So, you can follow us for more updates.

Comments

Popular posts from this blog

Control Statements in c language

So, Today we are going on new topic name control statements in C language. In which we read Looping(For, While and Do While), Jumping(Break, goto and Continue) and Decision Control statements(Switch, If, If Else and  If else if ladder)  in C. Before you read this article May you also like our previous posts :-    Structure Of C Language Program   Variables & Datatypes In C Language    Format Specifier In C Programming  .   It may help you to understanding it. A Statement is the smallest unit that is a complete instruction in itself statements contains expression and usually end with a semicolon. Statements are of two Types:- Types of Statements in C  1. Sequential Statement   2. Control Statement Sequential Statements are statements which are executed by one in sequential manner. Control Statements are the statements which alter the flow of execution and provide better control to the programme. On the flow of execution. The...

Array in C Language Btech Bca Notes

 Array in C Language Btech Bca Notes An array is a data form that can hold several values all of the same type. An array is a collection of variable of the same type that are referral to by a common name. Also Read:   Beginner our view on C programming Language  . Array are vital for most programming language. They are collection of variables, which we call elements. Each of the element in an array is stored sequentially in the computeric memory.  This making it easy to  m anipulate them and navigate among them. Since all the elements in an array are of same type, array allows us to represent a group of similar elements as an ordered  sequence  and work on them as a whole (grouping together related data). Array organize data in such a way that it can be easily sorted. To create an array, we use a declaration statement. An array declaration should indicate three things: 1. The type of value to be stored in each element. 2. The name of the array. 3. The ...

Format Specifier In C Programming Btech BCA Notes

   Format Specifier In C Programming Btech BCA Notes Welcome, Hope you are doing well. Today we are talking about Foramat specifier in C language. We can also say Type Specifier In C.  So, Today we are read formate specifier as well as printf and scanf Formats in different situations and different conditions. Before you read this article May you also like our previous posts :-    Beginner our view on C programming Language     Structure Of C Language Program   Variables & Datatypes In C Language  . It may help you to boost Your Information. In C Programming language, Types specifier is a special piece of code which is used during the input and output. Type specifier inform the compiler about the type of data which will be entered or displayed during an input output operation. Input mans reading data from keyword while output means displaying data either on screen or a printer. In c – Language every datatype has its own type specifier...