SlideShare a Scribd company logo
Passing Stuctures to Function
Presented By Azeem Sarwar,
Habib Rana, Asaduallah
ARID AGRICULTURE UNIVERSITY RAWALPINDI
Stucture in Function
• pass structures as an argument to
a function, and use them in your
program.Given below a sample
programm.
• Programm
• struct abc{
int a; int b; };
void Show(abc a,abc b)
{ abc L;
L.a = k.a+k.b;
cout<<”Sum :”<<sum;
}
int main(){
abc k;
Cout<<”enter your numbn”;
cin>>k1.a>>k2.b;
show(k1,k2);
return 0;
}
Programm to find total length
in feet and inch?
#include<iostream>
using namespace std;
struct dist{
int feet;
int inches;
};
void presum(dist l1,dist l2)
{
dist l3;
l3.feet=l1.feet+l2.feet+(l1.inches+l2.inches/1
2;
l3.inches=(l1.inches+l2.inches)%12;
cout<<"total feet:"<<l3.feet<<endl;
cout<<"total inch:"<<l3.inches;
cout<<"total
length:"<<l3.feet<<"."<<l3.inches;
}
int main()
{
dist l1,l2;
cout<<"enter length "<<endl;
cout<<"Enter length in feet"<<endl;
cin>>l1.feet;
cout<<"enter length in inchesn";
cin>>l1.inches;
cout<<"Enter length"<<endl;
cout<<"Enter length in feet"<<endl;
cin>>l2.feet;
cout<<"Enter length in
inches"<<endl;
cin>>l2.inches;
presum(l1,l2);
}
Example 2: Returning
structure from function in C++
#include<iostream>
using namespace std;
struct person{
char name[20];
int age;
double salery;
};
person getdata(person){
person l1;
cout<<"Enter name of person "<<endl;
cin.get(l1.name,50);
cout<<endl<<"Enter age of person"<<endl;
cin>>l1.age;
cout<<"Enter salery of person"<<endl;
cin>>l1.salery;
return l1;
}
void display(person l1)
{
cout<<"ninformation of personn";
cout<<"Name :"<<l1.name<<endl;
cout<<"Age :"<<l1.age<<endl;
cout<<"salary :"<<l1.salery<<endl;
}
int main()
{
person l1;
l1=getdata(l1);
display(l1);
return 0;
}
Input a number and print of
table its numer and next to
number by pasing function to
stucture
Passing stucture to function
#include<iostream>
#include<windows.h>
using namespace std;
struct abc{
int i;
int j;
};
void tabl(abc l){
for(l.j=1;l.j<=10;l.j++)
{
cout<<l.j<<" x "<<l.i<<" = "<<l.j*l.i<<"tt";
cout<<l.j<<" x "<<l.i+1<<"="<<l.j*(l.i+1)<<"tt";
cout<<l.j<<" x "<<l.i+2<<"="<<l.j*(l.i+2)<<endl;
}
cout<<endl;
for(l.j=10;l.j>=1;l.j--)
{
cout<<l.j<<"x"<<l.i<<" = "<<l.j*l.i<<"tt";
cout<<l.j<<" x "<<l.i+1<<"="<<l.j*(l.i+1)<<"tt";
cout<<l.j<<" x "<<l.i+2<<"="<<l.j*(l.i+2)<<endl;
}
}
int main()
{
abc l;
cout<<"Enter your numbern";
cin>>l.i;
tabl(l);
}
output

More Related Content

What's hot

Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
Vikas Dongre
 
Arithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CArithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded C
Vikas Dongre
 
6nullables in c#
6nullables in c#6nullables in c#
6nullables in c#
Sireesh K
 
Operators in mule dataweave
Operators in mule dataweaveOperators in mule dataweave
Operators in mule dataweave
Ramakrishna kapa
 
CS151 Functions lecture
CS151 Functions lectureCS151 Functions lecture
CS151 Functions lecture
Rudy Martinez
 
Cosc 2425 project 2 part 1 implement the following c++ code
Cosc 2425   project 2 part 1 implement the following c++ code Cosc 2425   project 2 part 1 implement the following c++ code
Cosc 2425 project 2 part 1 implement the following c++ code
AISHA232980
 
뱅크샐러드 파이썬맛 레시피
뱅크샐러드 파이썬맛 레시피뱅크샐러드 파이썬맛 레시피
뱅크샐러드 파이썬맛 레시피
겨울 정
 
Efficiently Performing Arithmetic Operation over Fq18 Extension Field
Efficiently Performing Arithmetic Operation over Fq18 Extension FieldEfficiently Performing Arithmetic Operation over Fq18 Extension Field
Efficiently Performing Arithmetic Operation over Fq18 Extension Field
Md. Al-Amin Khandaker Nipu
 
Adding To the Leaf Pile
Adding To the Leaf PileAdding To the Leaf Pile
Adding To the Leaf Pile
stuporglue
 
Custom Parameters in Hadoop Using Map Reduce
Custom Parameters in Hadoop Using Map ReduceCustom Parameters in Hadoop Using Map Reduce
Custom Parameters in Hadoop Using Map Reduce
FinTechopedia
 
Include
IncludeInclude
Include
zniker
 
Ninth session
Ninth sessionNinth session
Ninth session
AliMohammad155
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloadingDeepak Singh
 
Two-StageCreation
Two-StageCreationTwo-StageCreation
Two-StageCreationgillygize
 
Asynchronous Python at Kumparan
Asynchronous Python at KumparanAsynchronous Python at Kumparan
Asynchronous Python at Kumparan
Bayu Aldi Yansyah
 
Currying in JavaScript
Currying in JavaScriptCurrying in JavaScript
Currying in JavaScript
Ideas2IT Technologies
 
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
Attila Szucs
 

What's hot (19)

Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
 
Arithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CArithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded C
 
6nullables in c#
6nullables in c#6nullables in c#
6nullables in c#
 
Operators in mule dataweave
Operators in mule dataweaveOperators in mule dataweave
Operators in mule dataweave
 
CS151 Functions lecture
CS151 Functions lectureCS151 Functions lecture
CS151 Functions lecture
 
Cosc 2425 project 2 part 1 implement the following c++ code
Cosc 2425   project 2 part 1 implement the following c++ code Cosc 2425   project 2 part 1 implement the following c++ code
Cosc 2425 project 2 part 1 implement the following c++ code
 
뱅크샐러드 파이썬맛 레시피
뱅크샐러드 파이썬맛 레시피뱅크샐러드 파이썬맛 레시피
뱅크샐러드 파이썬맛 레시피
 
Efficiently Performing Arithmetic Operation over Fq18 Extension Field
Efficiently Performing Arithmetic Operation over Fq18 Extension FieldEfficiently Performing Arithmetic Operation over Fq18 Extension Field
Efficiently Performing Arithmetic Operation over Fq18 Extension Field
 
Adding To the Leaf Pile
Adding To the Leaf PileAdding To the Leaf Pile
Adding To the Leaf Pile
 
Custom Parameters in Hadoop Using Map Reduce
Custom Parameters in Hadoop Using Map ReduceCustom Parameters in Hadoop Using Map Reduce
Custom Parameters in Hadoop Using Map Reduce
 
Include
IncludeInclude
Include
 
Ninth session
Ninth sessionNinth session
Ninth session
 
Fp12_Efficient_SCM
Fp12_Efficient_SCMFp12_Efficient_SCM
Fp12_Efficient_SCM
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloading
 
Two-StageCreation
Two-StageCreationTwo-StageCreation
Two-StageCreation
 
Asynchronous Python at Kumparan
Asynchronous Python at KumparanAsynchronous Python at Kumparan
Asynchronous Python at Kumparan
 
Currying in JavaScript
Currying in JavaScriptCurrying in JavaScript
Currying in JavaScript
 
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
Distributing C# Applications with Apache Spark (TechEd 2017, Prague)
 
JavaScript intro
JavaScript introJavaScript intro
JavaScript intro
 

Similar to Passing stuctures to function

Reference Parameter, Passing object by reference, constant parameter & Defaul...
Reference Parameter, Passing object by reference, constant parameter & Defaul...Reference Parameter, Passing object by reference, constant parameter & Defaul...
Reference Parameter, Passing object by reference, constant parameter & Defaul...
Meghaj Mallick
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
LPU
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
Thooyavan Venkatachalam
 
C++
C++C++
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
imtiazalijoono
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
somu rajesh
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
Vikas Sharma
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
Vincent Pradeilles
 
Java 8
Java 8Java 8
Java 8
vilniusjug
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 

Similar to Passing stuctures to function (20)

Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Reference Parameter, Passing object by reference, constant parameter & Defaul...
Reference Parameter, Passing object by reference, constant parameter & Defaul...Reference Parameter, Passing object by reference, constant parameter & Defaul...
Reference Parameter, Passing object by reference, constant parameter & Defaul...
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C++
C++C++
C++
 
Lec-1c.pdf
Lec-1c.pdfLec-1c.pdf
Lec-1c.pdf
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
C++ Question
C++ QuestionC++ Question
C++ Question
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Java 8
Java 8Java 8
Java 8
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
L4 functions
L4 functionsL4 functions
L4 functions
 

More from ALI RAZA

Structure
StructureStructure
Structure
ALI RAZA
 
Recursion
RecursionRecursion
Recursion
ALI RAZA
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
ALI RAZA
 
Algorithm Development
Algorithm DevelopmentAlgorithm Development
Algorithm Development
ALI RAZA
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
ALI RAZA
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Array sorting
Array sortingArray sorting
Array sorting
ALI RAZA
 
Array programs
Array programsArray programs
Array programs
ALI RAZA
 
2D-Array
2D-Array 2D-Array
2D-Array
ALI RAZA
 
Quiz game documentary
Quiz game documentaryQuiz game documentary
Quiz game documentary
ALI RAZA
 
Function pass by value,function pass by reference
Function pass by value,function pass by reference Function pass by value,function pass by reference
Function pass by value,function pass by reference
ALI RAZA
 
Drug Addiction 39 Slides
Drug Addiction 39 SlidesDrug Addiction 39 Slides
Drug Addiction 39 Slides
ALI RAZA
 
Drug Addiction Original 51 Slides
Drug Addiction Original 51 SlidesDrug Addiction Original 51 Slides
Drug Addiction Original 51 Slides
ALI RAZA
 
Basic general knowledge
Basic general knowledgeBasic general knowledge
Basic general knowledge
ALI RAZA
 
Dil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shamsDil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shams
ALI RAZA
 
Pathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-completePathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-complete
ALI RAZA
 
Husne akhlaq
Husne akhlaqHusne akhlaq
Husne akhlaq
ALI RAZA
 
Parts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examplesParts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examples
ALI RAZA
 
Quik tips
Quik tipsQuik tips
Quik tips
ALI RAZA
 

More from ALI RAZA (20)

Structure
StructureStructure
Structure
 
Recursion
RecursionRecursion
Recursion
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Algorithm Development
Algorithm DevelopmentAlgorithm Development
Algorithm Development
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Array sorting
Array sortingArray sorting
Array sorting
 
Array programs
Array programsArray programs
Array programs
 
2D-Array
2D-Array 2D-Array
2D-Array
 
Quiz game documentary
Quiz game documentaryQuiz game documentary
Quiz game documentary
 
Function pass by value,function pass by reference
Function pass by value,function pass by reference Function pass by value,function pass by reference
Function pass by value,function pass by reference
 
Drug Addiction 39 Slides
Drug Addiction 39 SlidesDrug Addiction 39 Slides
Drug Addiction 39 Slides
 
Drug Addiction Original 51 Slides
Drug Addiction Original 51 SlidesDrug Addiction Original 51 Slides
Drug Addiction Original 51 Slides
 
Basic general knowledge
Basic general knowledgeBasic general knowledge
Basic general knowledge
 
Dil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shamsDil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shams
 
Pathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-completePathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-complete
 
Husne akhlaq
Husne akhlaqHusne akhlaq
Husne akhlaq
 
Parts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examplesParts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examples
 
Quik tips
Quik tipsQuik tips
Quik tips
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 

Passing stuctures to function

  • 1. Passing Stuctures to Function Presented By Azeem Sarwar, Habib Rana, Asaduallah ARID AGRICULTURE UNIVERSITY RAWALPINDI
  • 2. Stucture in Function • pass structures as an argument to a function, and use them in your program.Given below a sample programm. • Programm • struct abc{ int a; int b; }; void Show(abc a,abc b) { abc L; L.a = k.a+k.b; cout<<”Sum :”<<sum; } int main(){ abc k; Cout<<”enter your numbn”; cin>>k1.a>>k2.b; show(k1,k2); return 0; }
  • 3. Programm to find total length in feet and inch?
  • 4. #include<iostream> using namespace std; struct dist{ int feet; int inches; }; void presum(dist l1,dist l2) { dist l3; l3.feet=l1.feet+l2.feet+(l1.inches+l2.inches/1 2; l3.inches=(l1.inches+l2.inches)%12; cout<<"total feet:"<<l3.feet<<endl; cout<<"total inch:"<<l3.inches; cout<<"total length:"<<l3.feet<<"."<<l3.inches; } int main() { dist l1,l2; cout<<"enter length "<<endl; cout<<"Enter length in feet"<<endl; cin>>l1.feet; cout<<"enter length in inchesn"; cin>>l1.inches; cout<<"Enter length"<<endl; cout<<"Enter length in feet"<<endl; cin>>l2.feet; cout<<"Enter length in inches"<<endl; cin>>l2.inches; presum(l1,l2); }
  • 5.
  • 6. Example 2: Returning structure from function in C++
  • 7. #include<iostream> using namespace std; struct person{ char name[20]; int age; double salery; }; person getdata(person){ person l1; cout<<"Enter name of person "<<endl; cin.get(l1.name,50); cout<<endl<<"Enter age of person"<<endl; cin>>l1.age; cout<<"Enter salery of person"<<endl; cin>>l1.salery; return l1; } void display(person l1) { cout<<"ninformation of personn"; cout<<"Name :"<<l1.name<<endl; cout<<"Age :"<<l1.age<<endl; cout<<"salary :"<<l1.salery<<endl; } int main() { person l1; l1=getdata(l1); display(l1); return 0; }
  • 8.
  • 9. Input a number and print of table its numer and next to number by pasing function to stucture
  • 10. Passing stucture to function #include<iostream> #include<windows.h> using namespace std; struct abc{ int i; int j; }; void tabl(abc l){ for(l.j=1;l.j<=10;l.j++) { cout<<l.j<<" x "<<l.i<<" = "<<l.j*l.i<<"tt"; cout<<l.j<<" x "<<l.i+1<<"="<<l.j*(l.i+1)<<"tt"; cout<<l.j<<" x "<<l.i+2<<"="<<l.j*(l.i+2)<<endl; } cout<<endl; for(l.j=10;l.j>=1;l.j--) { cout<<l.j<<"x"<<l.i<<" = "<<l.j*l.i<<"tt"; cout<<l.j<<" x "<<l.i+1<<"="<<l.j*(l.i+1)<<"tt"; cout<<l.j<<" x "<<l.i+2<<"="<<l.j*(l.i+2)<<endl; } } int main() { abc l; cout<<"Enter your numbern"; cin>>l.i; tabl(l); }