SlideShare a Scribd company logo
DISCOVER . LEARN . EMPOWER
Structure: Structure and functions, Structures
and pointers
INSTITUTE - UIE
DEPARTMENT- ACADEMIC UNIT-2
Bachelor of Engineering (Computer Science & Engineering)
Subject Name: Introduction to Problem Solving
Code:23CSH-101
Introduction to
Problem Solving
Course Objectives
2
The course aims to provide exposure to problem-
solving through programming.
The course aims to raise the programming skills
of students via logic building capability.
With knowledge of C programming language,
students would be able to model real world
problems.
3
CO
Number
Course Outcome
CO1 Remember the concepts related to fundamentals of C language,
draw flowcharts and write algorithm/pseudocode.
CO2 Understand the way of execution and debug programs in C
language.
CO3 Apply various constructs, loops, functions to solve mathematical
and scientific problem.
CO4 Analyze the dynamic behavior of memory by the use of pointers.
CO5 Design and develop modular programs for real world problems
using control structure and selection structure.
Course Outcomes
Scheme of Evaluation
4
Structure and Pointers
• Pointer to structure: Pointer which stores address of structure is called as “Pointer to
Structure “.
• Explanation :
1. sptr is pointer to structure address.
2. -> and (*). both represents the same.
3. These operators are used to access data member of structure by using structure’s
pointer.
5
• Example: Program to create a structure and display the content using
pointer.
#include<stdio.h>
struct team {
char *name;
int members;
char captain[20];
}
t1 = {"India",11,"Dhoni"} , *sptr = &t1;
int main()
{
printf("nTeam : %s",(*sptr).name);
printf("nMemebers : %d",sptr->members);
printf("nCaptain : %s",(*sptr).captain);
return 0;
}
6
Output:
7
Summary
A structure can be passed to
any function from main
function or from any sub
function.
Structure definition will be
available within the function
only.
It won’t be available to other
functions unless it is passed to
those functions by value or by
address
Else, we have to declare
structure variable as global
variable. That means, structure
variable should be declared
outside the main function. So,
this structure will be visible to
all the functions in a C program.
To access members of a
structure using pointers, we use
the -> operator.
We can also initialize the array
of structures using the same
syntax as that for initializing
arrays.
Frequently Asked Questions
Q1 Write a Program to enter the employee Information & display the data passing Structures By Using
Pointers
Expected Output:
Enter the name of the Employee : John
Enter the Employee Id : 16
Enter Experience of the Employee : 3
---------Details List---------
Employee Name : ram
Employee Id : 16
Employee Experience : 3
Solution:
8
9
Assessment Questions:
10
1. Write a Program to demonstrate How to return multiple values from a function in C?
2. Program to add two distances in inch-feet system(Passing structure).
Discussion forum
PROBLEM:
Write a Program to add two complex numbers
Using (Passing struct by reference).
11
REFERENCES
Reference Books
1. Programming in C by Reema Thareja.
2. Programming in ANSI C by E. Balaguruswamy, Tata McGraw Hill.
3. Programming with C (Schaum's Outline Series) by Byron Gottfried Jitender
Chhabra, Tata McGraw Hill.
4. The C Programming Language by Brian W. Kernighan, Dennis Ritchie, Pearson
education.
Websites:
1. https://fresh2refresh.com/c-programming/c-passing-struct-to-function/
2. https://www.geeksforgeeks.org/how-to-pass-or-return-a-structure-to-from-a-
function-in-c-c/
3. https://www.studytonight.com/c/pointers-to-structure-in-c.php
4. https://dev.to/mikkel250/structures-and-pointers-in-c-n6i
5. https://www.programiz.com/c-programming/c-structures-pointers
YouTube Links:
1. https://www.youtube.com/watch?v=4HC8X966Q5M
2. https://www.youtube.com/watch?v=VF40lxbXR_0
12
THANK YOU

More Related Content

Similar to Lecture 3.2.4 C pointer to Structure.pptx (20)

PDF
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
PDF
data Integrative Programming untuk pemula.pdf
loliktry1
 
PPTX
Full Basic Programming in c material ppt
Rajendra400540
 
PDF
Deepakkumarassignmentnumberdiles1 01.pdf
anshssm07
 
PDF
GE3151 PSPP _Unit 1 notes and Question bank.pdf
Guru Nanak Technical Institutions
 
DOC
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
PDF
IP Lab Manual for Kerala University 3 Year UG Programme
SAFAD ISMAIL
 
DOCX
Mit4021–%20 c# and .net
smumbahelp
 
PPT
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
 
PPTX
Principles of object oriented programing
Ahammed Alamin
 
PDF
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
PDF
C programming
Raja Balan
 
PDF
Cd lab manual
Haftu Hagos
 
PPTX
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
PPT
trial
guest469fdc4
 
PPTX
object oriented programming part inheritance.pptx
urvashipundir04
 
PPTX
DS functions-1.pptx
HarikishnaKNHk
 
PDF
T2
lksoo
 
PPTX
UNIT IC programming notes university file
ANISHYAPIT
 
DOCX
Bca1020 programming in c
smumbahelp
 
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
data Integrative Programming untuk pemula.pdf
loliktry1
 
Full Basic Programming in c material ppt
Rajendra400540
 
Deepakkumarassignmentnumberdiles1 01.pdf
anshssm07
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
Guru Nanak Technical Institutions
 
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
IP Lab Manual for Kerala University 3 Year UG Programme
SAFAD ISMAIL
 
Mit4021–%20 c# and .net
smumbahelp
 
U19CS101 - PPS Unit 4 PPT (1).ppt
Manivannan837728
 
Principles of object oriented programing
Ahammed Alamin
 
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
C programming
Raja Balan
 
Cd lab manual
Haftu Hagos
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
object oriented programming part inheritance.pptx
urvashipundir04
 
DS functions-1.pptx
HarikishnaKNHk
 
T2
lksoo
 
UNIT IC programming notes university file
ANISHYAPIT
 
Bca1020 programming in c
smumbahelp
 

Recently uploaded (20)

PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PPTX
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
PDF
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PPTX
Precedence and Associativity in C prog. language
Mahendra Dheer
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PDF
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PPTX
Ground improvement techniques-DEWATERING
DivakarSai4
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
Zero Carbon Building Performance standard
BassemOsman1
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Precedence and Associativity in C prog. language
Mahendra Dheer
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Ground improvement techniques-DEWATERING
DivakarSai4
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
Ad

Lecture 3.2.4 C pointer to Structure.pptx

  • 1. DISCOVER . LEARN . EMPOWER Structure: Structure and functions, Structures and pointers INSTITUTE - UIE DEPARTMENT- ACADEMIC UNIT-2 Bachelor of Engineering (Computer Science & Engineering) Subject Name: Introduction to Problem Solving Code:23CSH-101
  • 2. Introduction to Problem Solving Course Objectives 2 The course aims to provide exposure to problem- solving through programming. The course aims to raise the programming skills of students via logic building capability. With knowledge of C programming language, students would be able to model real world problems.
  • 3. 3 CO Number Course Outcome CO1 Remember the concepts related to fundamentals of C language, draw flowcharts and write algorithm/pseudocode. CO2 Understand the way of execution and debug programs in C language. CO3 Apply various constructs, loops, functions to solve mathematical and scientific problem. CO4 Analyze the dynamic behavior of memory by the use of pointers. CO5 Design and develop modular programs for real world problems using control structure and selection structure. Course Outcomes
  • 5. Structure and Pointers • Pointer to structure: Pointer which stores address of structure is called as “Pointer to Structure “. • Explanation : 1. sptr is pointer to structure address. 2. -> and (*). both represents the same. 3. These operators are used to access data member of structure by using structure’s pointer. 5
  • 6. • Example: Program to create a structure and display the content using pointer. #include<stdio.h> struct team { char *name; int members; char captain[20]; } t1 = {"India",11,"Dhoni"} , *sptr = &t1; int main() { printf("nTeam : %s",(*sptr).name); printf("nMemebers : %d",sptr->members); printf("nCaptain : %s",(*sptr).captain); return 0; } 6 Output:
  • 7. 7 Summary A structure can be passed to any function from main function or from any sub function. Structure definition will be available within the function only. It won’t be available to other functions unless it is passed to those functions by value or by address Else, we have to declare structure variable as global variable. That means, structure variable should be declared outside the main function. So, this structure will be visible to all the functions in a C program. To access members of a structure using pointers, we use the -> operator. We can also initialize the array of structures using the same syntax as that for initializing arrays.
  • 8. Frequently Asked Questions Q1 Write a Program to enter the employee Information & display the data passing Structures By Using Pointers Expected Output: Enter the name of the Employee : John Enter the Employee Id : 16 Enter Experience of the Employee : 3 ---------Details List--------- Employee Name : ram Employee Id : 16 Employee Experience : 3 Solution: 8
  • 9. 9
  • 10. Assessment Questions: 10 1. Write a Program to demonstrate How to return multiple values from a function in C? 2. Program to add two distances in inch-feet system(Passing structure).
  • 11. Discussion forum PROBLEM: Write a Program to add two complex numbers Using (Passing struct by reference). 11
  • 12. REFERENCES Reference Books 1. Programming in C by Reema Thareja. 2. Programming in ANSI C by E. Balaguruswamy, Tata McGraw Hill. 3. Programming with C (Schaum's Outline Series) by Byron Gottfried Jitender Chhabra, Tata McGraw Hill. 4. The C Programming Language by Brian W. Kernighan, Dennis Ritchie, Pearson education. Websites: 1. https://fresh2refresh.com/c-programming/c-passing-struct-to-function/ 2. https://www.geeksforgeeks.org/how-to-pass-or-return-a-structure-to-from-a- function-in-c-c/ 3. https://www.studytonight.com/c/pointers-to-structure-in-c.php 4. https://dev.to/mikkel250/structures-and-pointers-in-c-n6i 5. https://www.programiz.com/c-programming/c-structures-pointers YouTube Links: 1. https://www.youtube.com/watch?v=4HC8X966Q5M 2. https://www.youtube.com/watch?v=VF40lxbXR_0 12