This presentation is based on variables and constants in C programming language.
In this presentation I have covered definition , Uses , Syntax and Examples in detailed manner.
Variables and Constants
AnOverview of Memory Storage in C
BCA Sem-1
Name : ………….
Enroll.no.: …………….
RESPECTED FACULTY :
…………………
PRESENTED BY :
2.
In C programming,variables and constants are
two fundamental elements that store values in
memory.
3.
Introduction to Variablesand Constants
❏ Variables and constants are key components in C.
❏ Variables hold values that can change during program
execution.
❏ Constants store fixed values that cannot be modified once
defined.
4.
Variables in C
➢A variable is a named memory location.
➢ The value stored in a variable can change during program
execution.
➢ Variables have types that determine what kind of data they store
(e.g., int, float, char).
Declaring Variables
in C
Syntax: data_type variable_name;
A variable is a named memory location used to store data that can be
changed during the execution of a program.
Constants in C
➢Constants are fixed values.
➢ Their value cannot be changed during the execution of the program.
➢ There are different types of constants: literal constants, defined
constants, and constant variables.
A constant is a fixed value that, once defined, cannot be changed during the
program’s execution.
Types of Constants
1.Literal Constants:
e.g., 5, 'A', 3.14
2. Defined Constants:
Using #define
3. Constant Variables:
Usingconst
9.
Variables vs Constants(Key Differences)
★ Variables can change their value during program
execution, while constants cannot.
★ Constants are used to store values that should
remain the same throughout the program.
Conclusion
❖ Variables andconstants play a crucial role in
efficient memory management.
❖ Use variables for data that changes and constants
for fixed values.
❖ Understanding when to use each will lead to
cleaner, more maintainable code.