SlideShare a Scribd company logo
C programming language:- Introduction to C Programming - Overview and Importance of C .pptx
A Glimpse into C's History
• C was created in 1972 by Dennis Ritchie at Bell Labs.
• It emerged from the need for a language that was both
powerful and portable across different machines.
• C borrowed elements from earlier languages like BCPL
and B.
Why C Matters
• C is a foundational language for many modern
programming languages.
• It offers precise control over hardware, making it ideal
for system programming.
• C's efficiency and speed make it perfect for
performance-critical applications.
C in Action: Real-World Applications
• C forms the foundation of the Unix operating system, a
cornerstone of modern computing.
• Embedded systems, prevalent in everyday devices like
smartphones and automobiles, heavily rely on C.
• C's efficiency makes it a favorite for graphics
programming and game development.
Structure of C Programs
• A C program follows a well-defined structure.
• Understanding this structure is essential for
writing effective C programs.
A Stepping Stone to Programming
Greatness
• C equips you with a solid foundation for programming
concepts.
• Mastering C opens doors to a vast array of programming
opportunities.
• The knowledge gained from C empowers you to tackle
more complex languages.
Building Blocks of a C Program
• Preprocessor Directives: Instructions for the preprocessor, like #include for
header files.
• Header Files: Contain essential declarations and function prototypes. (e.g.,
stdio.h for input/output)
• Global Variables: Variables declared outside functions, accessible throughout the
program.
• Function Prototypes: Declarations of functions before their definition, ensuring
proper calling.
• Main Function: The program's entry point, where execution begins.
• Code Block: The core logic of the program, enclosed in curly braces {}.
Sample C Program: Hello, World!
#include <stdio.h>
int main() {
printf("Hello,
World!n");
return 0;
}
Elements
of
C Language
Data Types in C
• Data types define the type of data a variable can
hold.
• Common data types include:
• int: Stores integers (whole numbers).
• float: Stores single-precision floating-point
numbers (decimal numbers).
• char: Stores a single character.
• double: Stores double-precision floating-point
numbers (more precise than float).
• void: Represents the absence of a value.
Character Set: The Building Blocks of Communication
• The character set defines the
characters recognized by the C
compiler.
• It encompasses letters
(uppercase and lowercase),
digits (0-9), special characters
(+, -, *, /, etc.), and whitespace
(spaces, tabs, newlines).
C Tokens: The Fundamental Units of Meaning
• C tokens are the smallest meaningful units in a C program.
• There are six primary types of tokens:
• Keywords: Predefined words with specific meanings (e.g., int, if, for).
• Identifiers: User-defined names for variables, functions (must start with a
letter or underscore and can contain letters, digits, and underscores).
• Constants: Fixed values that cannot be changed during program execution
(e.g., integers, floating-point numbers, characters).
• Operators: Symbols that perform operations on operands (e.g., +, -, *, /).
• Special Characters: Punctuation marks with specific meanings (e.g.,
parentheses, braces, brackets, semicolon).
• Strings: Sequences of characters enclosed in double quotes (e.g., "Hello,
World!").
Keywords: The Reserved Vocabulary of
C
• Keywords are reserved words with predefined meanings in C.
• They cannot be used as variable names or identifiers.
Some common keywords include:
• int: Denotes integer data type.
• float: Denotes single-precision floating-point data type.
• char: Denotes character data type.
• if: Used for conditional statements.
• else: Used for alternative execution paths.
• for: Used for loop constructs.
• while: Used for loop constructs based on a condition.
• do: Used for do-while loops.
• switch: Used for multi-way branching.
• break: Used to exit loops or switch statements.
• continue: Used to skip to the next iteration in a loop.
• return: Used to return a value from a function.
• void: Indicates no value or absence of a type.
Identifiers: Assigning Meaningful
Names
Identifiers are user-defined names
given to variables, functions, and other
program elements.
They must follow specific naming
rules:
• Start with a letter (uppercase or
lowercase) or an underscore (_).
• Can contain letters, digits, and
underscores.
• Case-sensitive (e.g., age and Age
are different identifiers).
• Cannot be reserved keywords in C.
Constants: Fixed Values that Endure
• Constants represent fixed values
that cannot be modified during
program execution.
• They are similar to constants in
mathematics, maintaining their
value throughout the program.
• Examples of constants in C:
• Integers (e.g., 10, -5)
• Floating-point numbers (e.g., 3.14, -
2.5e2)
• Characters (e.g., 'A', 'n')
• Character strings enclosed in double
quotes (e.g., "Hello, World!")
Variables: Containers for Changeable Data
• Variables act as named storage
locations that can hold data during
program execution.
• The data stored within a variable can
be changed throughout the program.
• To use a variable, you must first
declare it, specifying its data type
(e.g., int, float, char).
• After declaration, you can assign a
value to the variable using the
assignment operator (=).
Building with Blocks: Variable Declaration and
Assignment in C
int age
(declares an integer
variable named age)
float pi =
3.14159
(declares a float
variable named pi
and assigns the initial
value)
Variable Declaration: Allocating Space
• Variable declaration allocates memory space for
variables in your program.
• You specify the data type (e.g., int, float, char)
and the variable name.
• Examples of variable declarations:
Variable Assignment: Filling the
Blocks
• Variable assignment stores a value in the
memory location allocated for a variable.
• The assignment operator (=) is used to
assign a value to a variable.
• Example: age = 25; (assigns the value 25
to the previously declared integer
variable age)
C Operators: The Tools of the Trade
• Operators are symbols that perform
operations on operands (data values or
variables).
• C offers a rich set of operators for various
purposes.
• Common C operators include:
• Arithmetic operators (+, -, *, /, %) for mathematical
calculations.
• Relational operators (==, !=, <, >, <=, >=) for
comparisons.
• Logical operators (&&, ||, !) for logical operations
(AND, OR, NOT).
• Assignment operators (=, +=, -=, *=, /=, %=) for
assignment and combined operations.
• Increment/decrement operators (++, --) to increment
or decrement a variable's value.
Flow Control: Charting the Course
• Flow control statements dictate the
execution flow of your C program.
• They determine the order in which
program statements are executed.
• Common flow control statements include:
• if statements for conditional execution.
• if-else statements for two-way branching.
• switch statements for multi-way branching.
The if Statement
• The if statement executes a block of code only if a specified condition
is true.
• The condition is typically an expression that evaluates to true or false.
• Syntax:
if (condition) {
// code to execute if condition is true
}
The if-else
Statement
• The if-else statement provides two execution
paths based on a condition.
• If the condition is true, the code block following
if is executed.
• If the condition is false, the code block
following else is executed.
• Syntax:
if (condition) {
// code to execute if condition is true
} else {
// code to execute if condition is false
}
The switch Statement
• The switch statement allows for multi-way branching based
on the value of an expression.
• The expression is compared to a list of case values.
• If a match is found, the corresponding code block is executed.
• The break statement exits the switch after the matching code
block is executed.
• A default case can be included to handle unmatched values.
Looping Statements
• Looping statements enable the repeated execution of a
code block.
• This allows for automation of tasks and processing of
sequences of data.
• Common looping statements in C include:
⚬ for loop
⚬ while loop
⚬ do while loop
The for
Loop
• The for loop executes a code block repeatedly for a predetermined number
of iterations.
• It consists of three parts:
⚬ Initialization: Executes once before the loop starts (often used for
variable initialization).
⚬ Condition: Evaluated before each iteration; loop continues as long as the
condition is true.
⚬ Increment/Decrement: Executed after each iteration (often used for
updating loop counter).
• Syntax:
for (initialization; condition; increment/decrement) {
// code to be executed repeatedly
}
The while Loop
• The while loop executes a code block repeatedly as long as a
specified condition remains true.
• The condition is evaluated at the beginning of each iteration.
• Syntax:
while (condition) {
// code to be executed repeatedly
}
Do-While Loop
• The do-while loop executes a code block at least once,
followed by repeated execution as long as a condition is
true.
• The condition is evaluated after the code block is
executed.
• Syntax:
do {
// code to be executed at least once
} while (condition);
Arrays in C
• Arrays are collections of elements of the same data type
stored in contiguous memory locations.
• Elements are accessed using an index, starting from 0.
• Syntax:
data_type array_name[size];
Functions in C
• Functions are declared with a return
type, name, and parameter list
(optional).
• The function body contains the code to
be executed when the function is called.
• Syntax:
return_type
function_name(parameter_list) {
// function body
}
Calling Functions
• Functions are invoked by their name followed by
parentheses.
• Arguments (if any) are passed within the
parentheses during the call.
• The function executes its code and (optionally)
returns a value.
int result = add(5, 3); // Calling the add function and storing the
return value in result
• Structures are user-defined data
types that group variables of
different data types under a single
name.
• They create composite data
structures to represent real-world
entities.
• Unions are similar to structures,
but all members share the same
memory location.
Structures and Unions in C
Declaring Structures
• Structures are declared using the struct keyword followed by a
name and a member list enclosed in curly braces.
struct Student {
int age;
char name[50];
float gpa;
};
struct Student student1;
student1.age = 22;
strcpy(student1.name,
"Alice");
student1.gpa = 3.85;
struct Student student1;
student1.age = 22;
strcpy(student1.name,
"Alice");
Working with
Structures
• You can declare structure variables to hold data of the structure
type.
• Access structure members using the dot operator (.).
Union
s
• Unions are declared using the union keyword followed by a
name and a member list enclosed in curly braces.
• Similar to structures, members can be of different data types.
union Data {
int i;
float f;
char str[20];
};
Working with
Unions
• You declare union variables similar to structure variables.
• To access members, use the dot operator (.).
• Only one member can hold a valid value at a time.
union Data data;
data.i = 10; // Assigning an integer value
printf("Integer value: %dn", data.i);
data.f = 3.14; // Assigning a float value (overwrites
integer)
printf("Float value: %fn", data.f);
Introduction to Pointers in C
• Pointers are declared
using the asterisk (*)
symbol before the
data type they point
to.
int *ptr; // Declares a pointer 'ptr'
that can point to integer variables
int num = 10
int *ptr = &num // Assigns the memory address of
'num' to the pointer 'ptr'
The Address-of Operator
(&)
• The address-of operator (&) retrieves the memory
address of a variable.
THANKS

More Related Content

Similar to C programming language:- Introduction to C Programming - Overview and Importance of C .pptx (20)

PPT
Csharp
Swaraj Kumar
 
PPSX
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
PPTX
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
PPTX
C_plus_plus
Ralph Weber
 
PPT
Basic concept of c++
shashikant pabari
 
PPTX
FUNDAMENTAL OF C
KRUNAL RAVAL
 
PPTX
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
PPTX
C language
Mukul Kirti Verma
 
PPTX
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
PDF
C programming language
Mahmoud Eladawi
 
PPTX
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
PPT
Introduction to C
Janani Satheshkumar
 
PDF
Introduction to C programming
Kathmandu University
 
PPTX
Programming Language
Adeel Hamid
 
PPTX
C programmimng basic.ppt
ASIT Education
 
PPTX
Aspdot
Nishad Nizarudeen
 
PPTX
C programming tutorial for Beginner
sophoeutsen2
 
PPTX
C language
Rupanshi rawat
 
PPTX
C Language (All Concept)
sachindane
 
Csharp
Swaraj Kumar
 
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
C_plus_plus
Ralph Weber
 
Basic concept of c++
shashikant pabari
 
FUNDAMENTAL OF C
KRUNAL RAVAL
 
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
RutviBaraiya
 
C language
Mukul Kirti Verma
 
4 Introduction to C.pptxSSSSSSSSSSSSSSSS
EG20910848921ISAACDU
 
C programming language
Mahmoud Eladawi
 
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
Introduction to C
Janani Satheshkumar
 
Introduction to C programming
Kathmandu University
 
Programming Language
Adeel Hamid
 
C programmimng basic.ppt
ASIT Education
 
C programming tutorial for Beginner
sophoeutsen2
 
C language
Rupanshi rawat
 
C Language (All Concept)
sachindane
 

Recently uploaded (20)

PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Horarios de distribución de agua en julio
pegazohn1978
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Ad

C programming language:- Introduction to C Programming - Overview and Importance of C .pptx

  • 2. A Glimpse into C's History • C was created in 1972 by Dennis Ritchie at Bell Labs. • It emerged from the need for a language that was both powerful and portable across different machines. • C borrowed elements from earlier languages like BCPL and B.
  • 3. Why C Matters • C is a foundational language for many modern programming languages. • It offers precise control over hardware, making it ideal for system programming. • C's efficiency and speed make it perfect for performance-critical applications.
  • 4. C in Action: Real-World Applications • C forms the foundation of the Unix operating system, a cornerstone of modern computing. • Embedded systems, prevalent in everyday devices like smartphones and automobiles, heavily rely on C. • C's efficiency makes it a favorite for graphics programming and game development.
  • 5. Structure of C Programs • A C program follows a well-defined structure. • Understanding this structure is essential for writing effective C programs.
  • 6. A Stepping Stone to Programming Greatness • C equips you with a solid foundation for programming concepts. • Mastering C opens doors to a vast array of programming opportunities. • The knowledge gained from C empowers you to tackle more complex languages.
  • 7. Building Blocks of a C Program • Preprocessor Directives: Instructions for the preprocessor, like #include for header files. • Header Files: Contain essential declarations and function prototypes. (e.g., stdio.h for input/output) • Global Variables: Variables declared outside functions, accessible throughout the program. • Function Prototypes: Declarations of functions before their definition, ensuring proper calling. • Main Function: The program's entry point, where execution begins. • Code Block: The core logic of the program, enclosed in curly braces {}.
  • 8. Sample C Program: Hello, World! #include <stdio.h> int main() { printf("Hello, World!n"); return 0; }
  • 10. Data Types in C • Data types define the type of data a variable can hold. • Common data types include: • int: Stores integers (whole numbers). • float: Stores single-precision floating-point numbers (decimal numbers). • char: Stores a single character. • double: Stores double-precision floating-point numbers (more precise than float). • void: Represents the absence of a value.
  • 11. Character Set: The Building Blocks of Communication • The character set defines the characters recognized by the C compiler. • It encompasses letters (uppercase and lowercase), digits (0-9), special characters (+, -, *, /, etc.), and whitespace (spaces, tabs, newlines).
  • 12. C Tokens: The Fundamental Units of Meaning • C tokens are the smallest meaningful units in a C program. • There are six primary types of tokens: • Keywords: Predefined words with specific meanings (e.g., int, if, for). • Identifiers: User-defined names for variables, functions (must start with a letter or underscore and can contain letters, digits, and underscores). • Constants: Fixed values that cannot be changed during program execution (e.g., integers, floating-point numbers, characters). • Operators: Symbols that perform operations on operands (e.g., +, -, *, /). • Special Characters: Punctuation marks with specific meanings (e.g., parentheses, braces, brackets, semicolon). • Strings: Sequences of characters enclosed in double quotes (e.g., "Hello, World!").
  • 13. Keywords: The Reserved Vocabulary of C • Keywords are reserved words with predefined meanings in C. • They cannot be used as variable names or identifiers. Some common keywords include: • int: Denotes integer data type. • float: Denotes single-precision floating-point data type. • char: Denotes character data type. • if: Used for conditional statements. • else: Used for alternative execution paths. • for: Used for loop constructs. • while: Used for loop constructs based on a condition. • do: Used for do-while loops. • switch: Used for multi-way branching. • break: Used to exit loops or switch statements. • continue: Used to skip to the next iteration in a loop. • return: Used to return a value from a function. • void: Indicates no value or absence of a type.
  • 14. Identifiers: Assigning Meaningful Names Identifiers are user-defined names given to variables, functions, and other program elements. They must follow specific naming rules: • Start with a letter (uppercase or lowercase) or an underscore (_). • Can contain letters, digits, and underscores. • Case-sensitive (e.g., age and Age are different identifiers). • Cannot be reserved keywords in C.
  • 15. Constants: Fixed Values that Endure • Constants represent fixed values that cannot be modified during program execution. • They are similar to constants in mathematics, maintaining their value throughout the program. • Examples of constants in C: • Integers (e.g., 10, -5) • Floating-point numbers (e.g., 3.14, - 2.5e2) • Characters (e.g., 'A', 'n') • Character strings enclosed in double quotes (e.g., "Hello, World!")
  • 16. Variables: Containers for Changeable Data • Variables act as named storage locations that can hold data during program execution. • The data stored within a variable can be changed throughout the program. • To use a variable, you must first declare it, specifying its data type (e.g., int, float, char). • After declaration, you can assign a value to the variable using the assignment operator (=).
  • 17. Building with Blocks: Variable Declaration and Assignment in C
  • 18. int age (declares an integer variable named age) float pi = 3.14159 (declares a float variable named pi and assigns the initial value) Variable Declaration: Allocating Space • Variable declaration allocates memory space for variables in your program. • You specify the data type (e.g., int, float, char) and the variable name. • Examples of variable declarations:
  • 19. Variable Assignment: Filling the Blocks • Variable assignment stores a value in the memory location allocated for a variable. • The assignment operator (=) is used to assign a value to a variable. • Example: age = 25; (assigns the value 25 to the previously declared integer variable age)
  • 20. C Operators: The Tools of the Trade • Operators are symbols that perform operations on operands (data values or variables). • C offers a rich set of operators for various purposes. • Common C operators include: • Arithmetic operators (+, -, *, /, %) for mathematical calculations. • Relational operators (==, !=, <, >, <=, >=) for comparisons. • Logical operators (&&, ||, !) for logical operations (AND, OR, NOT). • Assignment operators (=, +=, -=, *=, /=, %=) for assignment and combined operations. • Increment/decrement operators (++, --) to increment or decrement a variable's value.
  • 21. Flow Control: Charting the Course • Flow control statements dictate the execution flow of your C program. • They determine the order in which program statements are executed. • Common flow control statements include: • if statements for conditional execution. • if-else statements for two-way branching. • switch statements for multi-way branching.
  • 22. The if Statement • The if statement executes a block of code only if a specified condition is true. • The condition is typically an expression that evaluates to true or false. • Syntax: if (condition) { // code to execute if condition is true }
  • 23. The if-else Statement • The if-else statement provides two execution paths based on a condition. • If the condition is true, the code block following if is executed. • If the condition is false, the code block following else is executed. • Syntax: if (condition) { // code to execute if condition is true } else { // code to execute if condition is false }
  • 24. The switch Statement • The switch statement allows for multi-way branching based on the value of an expression. • The expression is compared to a list of case values. • If a match is found, the corresponding code block is executed. • The break statement exits the switch after the matching code block is executed. • A default case can be included to handle unmatched values.
  • 25. Looping Statements • Looping statements enable the repeated execution of a code block. • This allows for automation of tasks and processing of sequences of data. • Common looping statements in C include: ⚬ for loop ⚬ while loop ⚬ do while loop
  • 26. The for Loop • The for loop executes a code block repeatedly for a predetermined number of iterations. • It consists of three parts: ⚬ Initialization: Executes once before the loop starts (often used for variable initialization). ⚬ Condition: Evaluated before each iteration; loop continues as long as the condition is true. ⚬ Increment/Decrement: Executed after each iteration (often used for updating loop counter). • Syntax: for (initialization; condition; increment/decrement) { // code to be executed repeatedly }
  • 27. The while Loop • The while loop executes a code block repeatedly as long as a specified condition remains true. • The condition is evaluated at the beginning of each iteration. • Syntax: while (condition) { // code to be executed repeatedly }
  • 28. Do-While Loop • The do-while loop executes a code block at least once, followed by repeated execution as long as a condition is true. • The condition is evaluated after the code block is executed. • Syntax: do { // code to be executed at least once } while (condition);
  • 29. Arrays in C • Arrays are collections of elements of the same data type stored in contiguous memory locations. • Elements are accessed using an index, starting from 0. • Syntax: data_type array_name[size];
  • 30. Functions in C • Functions are declared with a return type, name, and parameter list (optional). • The function body contains the code to be executed when the function is called. • Syntax: return_type function_name(parameter_list) { // function body }
  • 31. Calling Functions • Functions are invoked by their name followed by parentheses. • Arguments (if any) are passed within the parentheses during the call. • The function executes its code and (optionally) returns a value. int result = add(5, 3); // Calling the add function and storing the return value in result
  • 32. • Structures are user-defined data types that group variables of different data types under a single name. • They create composite data structures to represent real-world entities. • Unions are similar to structures, but all members share the same memory location. Structures and Unions in C
  • 33. Declaring Structures • Structures are declared using the struct keyword followed by a name and a member list enclosed in curly braces. struct Student { int age; char name[50]; float gpa; };
  • 34. struct Student student1; student1.age = 22; strcpy(student1.name, "Alice"); student1.gpa = 3.85; struct Student student1; student1.age = 22; strcpy(student1.name, "Alice"); Working with Structures • You can declare structure variables to hold data of the structure type. • Access structure members using the dot operator (.).
  • 35. Union s • Unions are declared using the union keyword followed by a name and a member list enclosed in curly braces. • Similar to structures, members can be of different data types. union Data { int i; float f; char str[20]; };
  • 36. Working with Unions • You declare union variables similar to structure variables. • To access members, use the dot operator (.). • Only one member can hold a valid value at a time. union Data data; data.i = 10; // Assigning an integer value printf("Integer value: %dn", data.i); data.f = 3.14; // Assigning a float value (overwrites integer) printf("Float value: %fn", data.f);
  • 37. Introduction to Pointers in C • Pointers are declared using the asterisk (*) symbol before the data type they point to. int *ptr; // Declares a pointer 'ptr' that can point to integer variables
  • 38. int num = 10 int *ptr = &num // Assigns the memory address of 'num' to the pointer 'ptr' The Address-of Operator (&) • The address-of operator (&) retrieves the memory address of a variable.