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. They are useful to write better and complex program. Control S

Beginner our view on C programming Language

  Beginner our view on C programming Language   Beginner ourview on C programming Language History about C programming Language. The founder or we can say developer of C programming language was Dennis Ritchie. He was found in  Bell labs USA. The Birth of C language is originally on 1972. After the time C is widely popular all around the world. C is also used in to develop many OS system some are Linux and Windows. Now days C is still widely used or popular language in Programming world. Here, we have a question is What is a Program ?  A Program is a set of instruction which on   execution by a machine produces a specific result. A machine needs set of instructions to perform an operation. Those set of instruction are contained in a program. What is program? What is Programming languages ? What Is a Programming Languages? Meaning- A programming language allows a programmer to develop instructions which can be executed by a machine. A programming language acts as an intermediate bet

What is Blogger? How we create a account on it.

What is Blogger ? How we create a account on it. Welcome to blog. Here I am talking about blog on blogger.com. Hope you guys like it, Thanks. Here, I will talk about Ø What is blog. Ø About blogger. Ø How to create an account on blogger. Ø Can we earn money to blog. What is Blog Blog is a kind of platform, where you can write your thinking about that particular topic. Also you can say blog is article which we write through blogger.com and WordPress, etc. After writing the blog we go to publish in internet. If we write on a unique content hope traffic will came on our blog. You should write a blog on different topics like - Games, Technical, programming, Knowledge, education, and many more you like. What is blogger.com     Blogger is website that manages by Google. Google bought blogger from Pyra labs in 2003.Blogger is free for all, it give space to our passion in his platform. Around the world millions of peoples are used blogger daily and post something every