Variables and Constants
An Overview of Memory Storage in C
BCA Sem-1
Name : ………….
Enroll.no.: …………….
RESPECTED FACULTY :
…………………
PRESENTED BY :
In C programming, variables and constants are
two fundamental elements that store values in
memory.
Introduction to Variables and 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.
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.
Example of Variables in C
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.
Example Constants of in C
Types of Constants
1. Literal Constants:
e.g., 5, 'A', 3.14
2. Defined Constants:
Using #define
3. Constant Variables:
Usingconst
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.
From LDP Material
From LDP
Material
From LDP Material
Conclusion
❖ Variables and constants 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.
Thank
You

VARIABLE AND CONSTANTS in C programming language.

  • 1.
    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.
  • 5.
  • 6.
    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.
  • 7.
  • 8.
    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.
  • 10.
  • 11.
  • 12.
  • 13.
    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.
  • 14.