0% found this document useful (0 votes)
3 views2 pages

Programming Methodology Chapter 4

The document provides an overview of constants, variables, and data types in C programming, detailing the character set, tokens, and various types of constants such as integer, real, single character, string, and backslash character constants. It explains the declaration and assignment of variables, including user-defined types and storage classes. Additionally, it covers the definition of symbolic constants using the #define directive.

Uploaded by

1064578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Programming Methodology Chapter 4

The document provides an overview of constants, variables, and data types in C programming, detailing the character set, tokens, and various types of constants such as integer, real, single character, string, and backslash character constants. It explains the declaration and assignment of variables, including user-defined types and storage classes. Additionally, it covers the definition of symbolic constants using the #define directive.

Uploaded by

1064578
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming: Constants, Variables, and Data Types

C Program Character Set

• Instructions formed using symbols and words according to syntax rules.


• Characters grouped into letters, digits, and special characters.
• White spaces ignored unless part of a string constant.
• Trigraph sequences used for unavailable characters on some keyboards.

C Program Tokens

• Smallest individual units in a C program.


• Six types of tokens used in C programming.

Integer Constants

• Sequence of digits.
• Types: Decimal, Octal, Hexadecimal.

Real Constants

• Represent quantities with fractional parts.


• Can be expressed in exponential notation.

Single Character Constants

• Single character enclosed in single quotes.


• Represented by ASCII values.

String Constants

• Sequence of characters in double quotes.


• No ASCII value.

Backslash Character Constants

• Special constants used in output functions.


• Known as escape sequences.

Variables

• Data names used to store values.


• Can change during program execution.
• Valid and invalid variable names.

Data Types

• Three classes: Primary, Derived, User-defined.


• Primary types: Integer, Character, Floating point, Double-precision, Void.
Declaring Variables

• Must be declared before use.


• Syntax: data_type v1, v2, vn;
• Local and global variables.

User-defined Type Declaration

• Allows defining an identifier for an existing data type.


• Syntax: typedef type identifier;

Declaration of Storage Class

• Variables have data type and storage class.


• Storage class specifies scope and lifetime.

Assigning Values to Variables

• Using = operator or scanf() function.


• Initialization during declaration.

Defining Symbolic Constants

• Use symbolic names for numeric values.


• Syntax: #define symbolic_name value
• Rules for defining and using symbolic constants.

You might also like