You are on page 1of 14

BENGAL SCHOOL OF TECHNOLOGY

(A COLLEGE OF PHARMACY)
SUGANDHA DELHI ROAD , NEAR CHINSURAH STATION ,
HOOGLY -712102 WESTBENGAL
TITLE : C PROGRAMMING VARIABLES AND DATATYPE

NAME: SHOUBHIK HALDER


ROLL NO: 19301922093
YEAR/SEMESTER:2nd/3rd
COURSE: B.PHARM
SUBJECT NAME: COMPUTER APPLICATION IN
PHARMACY
SUBJECT CODE: PT 381
CONTENTS

 DEFINITION
 WHAT IS C
 C- VARIABLES
 TYPES OF VARIABLES IN C
 Size Of Data Types In C
 C DATA TYPE
 IMPORTANCE OF C DATATYPES
 CONCLUSION
 REFERENCES
DEFINITION :
C is a programming language developed at AT & T’s Bell laboratories of
USA in 1972. It was designed and written by a man named Dennis Ritchie. In
the late seventies C began to replace the more familiar languages of that time
like PL/I, ALGOL , etc. No one pushed C. It wasn’t made the ‘official’ Bell
Lab’s language. Thus, without any advertisement, C’s reputation spread and
its pool of users grew. Ritchie seems to have been rather surprised that so
many programmers preferred C to older languages like FORTRAN or PL/I,
or the newer ones like Pascal and APL. But thats what happened.
Possibly why C seems so popular is because it is reliable, simple
and easy to use. Moreover, in an industry where newer languages, tools and
technologies emerge and vanish day in and day out, a language that has
survived for more than three decades has to be really good.
WHAT IS C :
 C is a strongly typed language. What this means it that, the type of a
variable cannot be changed. Suppose we declared an integer type variable
so we cannot store character or a decimal number in that variable.
 There are set of rules to be followed while declaring variables and data
types in C Programming:-

 The 1st letter should be alphabet.


 Variables can be combination of alphabets and digits.
 Underscore (_) is the only special character allowed.
 Variables can be written in both Uppercase and Lowercase or combination
of both.
 Variables are Case Sensitive.
 No Spaces allowed between Characters.
 Variable name should not make use to the C Reserved Keywords.
 Variable name should not start with a number.
C- VARIABLES :
A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in C has a specific type, which determines the size
and layout of the variable's memory; the range of values that can be stored
within that memory; and the set of operations that can be applied to the variable.
The value of the C variable may get change in the program.
C variable might be belonging to any of the data type like int, float, char etc.
Rules for Naming a Variable in C
 The name of the variable must not begin with a digit.
 A variable name can consist of digits, alphabets, and even special
symbols such as an underscore ( _ ).
 A variable name must not have any keywords, for instance, float, int,
etc.
 There must be no spaces or blanks in the variable name.
 The C language treats lowercase and uppercase very differently, as it is
case sensitive. Usually, we keep the name of the variable in the lower
case.
TYPES OF VARIABLES IN C
There are many types of variables in c :
 1)local variable
 2)global variable
 3)static variable
 4)automatic variable
 5)external variable
Local Variable:
•A variable that is declared inside the function or block is called a local
variable.
• It must be declared at the start of the block.
EX:-
• void function1(){
int x=10;//local variable
}
Static Variable:
A variable that is declared with the static keyword is called static
variable.
•It retains its value between multiple function calls.
•EX:-
void function1(){
int x=10;//local variable
static int y=10;//static variable
x=x+1;
y=y+1;
printf("%d,%d",x,y);
Automatic Variable:
All variables in C that are declared inside the block, are automatic variables by
default. We can explicitly declare an automatic variable using auto keyword.
EX:-
void main(){
int x=10;//local variable (also automatic)
auto int y=20;//automatic variable
}
External Variable:
We can share a variable in multiple C source files by using an external variable. To
declare an external variable, you need to use extern keyword.
EX:-
extern int x=10;//external variable (also global)
lobal Variable:
A variable that is declared outside the function or block is called a global variable. Any
function can change the value of the global variable. It is available to all the functions.
It must be declared at the start of the block.
EX:-
int value=20;//global variable
void function1(){
int x=10;//local variable
Size Of Data Types In C
C DATA TYPE :

 Each variable in C has an associated data type. It specifies the type of


data that the variable can store like integer, character, floating, double, etc.
Each data type requires different amounts of memory and has some specific
operations which can be performed over it. The data type is a collection of
data with values having fixed values, meaning as well as its characteristics .

The data types in C can be classified as follows:

 PRIMITIVE DATE
 USER DEFINED DATE TYPES
 DERIVED TYPE
IMPORTANCE OF C DATATYPES:
C data types play a crucial role in programming as they determine the size,
memory allocation, and behavior of variables in a C program. Understanding
the importance of C data types is essential for writing efficient, reliable, and
portable code. Here are some key reasons why C data types are important:

 Memory Management: Each data type in C has a specific size, which determines
the amount of memory allocated to store variables of that type. Properly choosing
data types allows efficient use of memory, reducing memory waste and
optimizing the program's performance.

 Portability: C data types are standardized by the language specification, ensuring


consistency across different platforms and architectures. Using the appropriate
data types ensures that your code works correctly on various systems, making it
portable and independent of underlying hardware.

 Data Representation: Different data types represent different kinds of data, such as
integers, floating-point numbers, characters, etc. Choosing the right data type
ensures that data is represented accurately, preventing data loss or truncation.
CONCLUSION:
In conclusion, variables and data types are fundamental
concepts in C programming. They play a crucial role in defining
and storing data in memory, allowing programmers to
manipulate and work with different types of information
C remained the most popular programming language for more than
two decades in TIOBE Index – we are talking about a consistent lead in
the top 2.
C remained used to date for its unmatched performance and low-level
control. Most applications that make great use of C are system-level
applications – OS, Compilers, Interpreters, Databases, and Libraries.

undamental Data Types: Some common fundamental data types in C


are:
•int: Used to represent integers.
•float: Used to represent single-precision floating-point numbers.
•double: Used to represent double-precision floating-point numbers.
•char: Used to represent individual characters.
•_Bool: Used to represent boolean values (0 for false, 1 for true).
REFERENCES:

 Computer Applications in pharmacy”- William E. Fassett-Lea and Febiger,


600 South Washington Square, USA, (215)- Latest Edition.
 “Computer Application in Pharmaceutical Research and Development”-
Seans Ekins- Wiley – Interscience, A John Willey and Sons , INC
Publication, USA- Latest Edition.
 “Bioinformatics (Concept, Skills and Applications)” – S. C. Rastogi- CBS
Publishers and Distributors, 4596/1-A,11 Darya Gani, New Delhi- Latest
Edition.
 “Handbook of Computer Fundamentals”- R.S. Salaria, Khanna Publishing
House, New Delhi- Latest Edition.
THANK YOU

You might also like