SlideShare a Scribd company logo
1 of 20
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;
void main()
{
cout<<"abs(3.5): "<<abs(3.5)<<endl;
cout<<"abs(-3.5): "<<abs(-3.5)<<endl;
cout<<"ceil(59.76): "<<ceil(59.76)<<endl;
cout<<"ceil(-59.76): "<<ceil(-59.76)<<endl;
cout<<"exp(1) : "<<exp(1)<<endl;
cout<<"fabs(3.5): "<<fabs(3.5)<<endl;
cout<<"cos(0): "<<cos(0)<<endl;
cout<<"floor(40.8): "<<floor(40.8)<<endl;
cout<<"floor(-40.8): "<<floor(-40.8)<<endl;
cout<<"tolower(65): "<<tolower(65)<<endl;
cout<<"toupper(97) : "<<toupper(97)<<endl;
}
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;
void main()
{
cout<<"toupper(97) : "<<toupper(97)<<endl;
cout<<"toupper(42) : "<<toupper(42)<<endl;
cout<<"sqrt(4): "<<sqrt(4)<<endl;
cout<<"sqrt(-4): "<<sqrt(-4)<<endl;
}
#include<iostream>
using namespace std;
int square( int m ); // function prototype
//it can be int square( int );
int main()
{
for ( int x = 1; x <= 10; x++ )
cout << square( x ) << " "; //calling statement x is actual parameter
cout << endl;
return 0;
}
// Function definition
int square( int y ) // Heading y is Formal Parameter
{
return y * y; // The return Statement
}
#include<iostream>
using namespace std;
int square( int ); // function prototype
int main()
{
for ( int x = 1; x <= 10; x++ )
cout << square( x ) << " ";
cout << endl;
return 0;
}
// Function definition
int square( int y )
{
return y * y;
}
#include<iostream>
using namespace std;
int cube( int y ); // function prototype
int main()
{
int x;
for ( x = 1; x <= 10; x++ )
cout << cube( x ) << endl; //calling statement x is actual parameter
return 0;
}
// Function definition
int cube( int y ) // Heading y is Formal Parameter
{
return y * y * y;
}
#include<iostream>
using namespace std;
int maximum( int, int, int ); // function prototype
int main()
{
int a, b, c;
cout << "Enter three integers: "<<endl;
cin >> a >> b >> c;
// a, b and c below are arguments (actual parameters) to
// the maximum function call
cout << "Maximum is: " << maximum( a, b, c ) << endl;
return 0;
}
// Function maximum definition
// x, y and z below are parameters ( formal parameters) to
// the maximum function definition
int maximum( int x, int y, int z )
{
int max = x;
if ( y > max )
max = y;
if ( z > max )
max = z;
return max;
}
Programming Example
Programming Example
// Program: Largest
#include <iostream>
using namespace std;
double larger(double x, double y);
int main()
{
double num; //variable to hold the current number
double max; //variable to hold the larger number
int count; //loop control variable
cout << "Enter 10 numbers." << endl;
cin >> num; //Step 1
max = num; //Step 1
for (count = 1; count < 10; count++) //Step 2
{
cin >> num; //Step 2a
max = larger(max, num); //Step 2b
}
cout << "The largest number is " << max<< endl; //Step 3
return 0;
}//end main
double larger(double x, double y)
{
if (x >= y)
return x;
else
return y;
}
The return Statement
#include<iostream>
using namespace std;
int maximum( int, int, int ); // function prototype
int main()
{
int a, b, c;
cout << "Enter three integers: "<<endl;
cin >> a >> b >> c;
// a, b and c below are arguments (actual parameters) to
// the maximum function call
cout << "Maximum is: " << maximum( a, b, c ) << endl;
return 0;
}
// Function maximum definition
// x, y and z below are parameters ( formal parameters) to
// the maximum function definition
int maximum( int x, int y, int z )
{
int max = x;
return 0;
if ( y > max )
max = y;
if ( z > max )
max = z;
return max;
}
#include<iostream>
using namespace std;
int maximum( int, int, int ); // function prototype
int main()
{
int a, b, c;
return 0;
cout << "Enter three integers: "<<endl;
cin >> a >> b >> c;
// a, b and c below are arguments (actual parameters) to
// the maximum function call
cout << "Maximum is: " << maximum( a, b, c ) << endl;
return 0;
}
// Function maximum definition
// x, y and z below are parameters ( formal parameters) to
// the maximum function definition
int maximum( int x, int y, int z )
{
int max = x;
if ( y > max )
max = y;
if ( z > max )
max = z;
return max;
}
ch6_additional.ppt

More Related Content

Similar to ch6_additional.ppt

c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 
Lecture no 3
Lecture no 3Lecture no 3
Lecture no 3hasi071
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2Warui Maina
 
Lecture 9_Classes.pptx
Lecture 9_Classes.pptxLecture 9_Classes.pptx
Lecture 9_Classes.pptxNelyJay
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Abdul Samee
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxShashiShash2
 

Similar to ch6_additional.ppt (20)

C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Project in programming
Project in programmingProject in programming
Project in programming
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
C++ file
C++ fileC++ file
C++ file
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
 
Lecture no 3
Lecture no 3Lecture no 3
Lecture no 3
 
C++ Programs
C++ ProgramsC++ Programs
C++ Programs
 
C++ practical
C++ practicalC++ practical
C++ practical
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Lecture 9_Classes.pptx
Lecture 9_Classes.pptxLecture 9_Classes.pptx
Lecture 9_Classes.pptx
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
 

More from LokeshK66

Iot application in smart cities .pptx
Iot    application in  smart  cities .pptxIot    application in  smart  cities .pptx
Iot application in smart cities .pptxLokeshK66
 
building mat.pptx
building mat.pptxbuilding mat.pptx
building mat.pptxLokeshK66
 
9781423902096_PPT_ch07.ppt
9781423902096_PPT_ch07.ppt9781423902096_PPT_ch07.ppt
9781423902096_PPT_ch07.pptLokeshK66
 
9781423902096_PPT_ch08.ppt
9781423902096_PPT_ch08.ppt9781423902096_PPT_ch08.ppt
9781423902096_PPT_ch08.pptLokeshK66
 
9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.pptLokeshK66
 
ch4_additional.ppt
ch4_additional.pptch4_additional.ppt
ch4_additional.pptLokeshK66
 
ch9_additional.ppt
ch9_additional.pptch9_additional.ppt
ch9_additional.pptLokeshK66
 
SQLSecurity.ppt
SQLSecurity.pptSQLSecurity.ppt
SQLSecurity.pptLokeshK66
 

More from LokeshK66 (8)

Iot application in smart cities .pptx
Iot    application in  smart  cities .pptxIot    application in  smart  cities .pptx
Iot application in smart cities .pptx
 
building mat.pptx
building mat.pptxbuilding mat.pptx
building mat.pptx
 
9781423902096_PPT_ch07.ppt
9781423902096_PPT_ch07.ppt9781423902096_PPT_ch07.ppt
9781423902096_PPT_ch07.ppt
 
9781423902096_PPT_ch08.ppt
9781423902096_PPT_ch08.ppt9781423902096_PPT_ch08.ppt
9781423902096_PPT_ch08.ppt
 
9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt9781423902096_PPT_ch09.ppt
9781423902096_PPT_ch09.ppt
 
ch4_additional.ppt
ch4_additional.pptch4_additional.ppt
ch4_additional.ppt
 
ch9_additional.ppt
ch9_additional.pptch9_additional.ppt
ch9_additional.ppt
 
SQLSecurity.ppt
SQLSecurity.pptSQLSecurity.ppt
SQLSecurity.ppt
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

ch6_additional.ppt

  • 1. #include<iostream> #include<cmath> #include<cstdlib> #include<cctype> using namespace std; void main() { cout<<"abs(3.5): "<<abs(3.5)<<endl; cout<<"abs(-3.5): "<<abs(-3.5)<<endl; cout<<"ceil(59.76): "<<ceil(59.76)<<endl; cout<<"ceil(-59.76): "<<ceil(-59.76)<<endl; cout<<"exp(1) : "<<exp(1)<<endl; cout<<"fabs(3.5): "<<fabs(3.5)<<endl; cout<<"cos(0): "<<cos(0)<<endl; cout<<"floor(40.8): "<<floor(40.8)<<endl; cout<<"floor(-40.8): "<<floor(-40.8)<<endl; cout<<"tolower(65): "<<tolower(65)<<endl; cout<<"toupper(97) : "<<toupper(97)<<endl; }
  • 2.
  • 3.
  • 4. #include<iostream> #include<cmath> #include<cstdlib> #include<cctype> using namespace std; void main() { cout<<"toupper(97) : "<<toupper(97)<<endl; cout<<"toupper(42) : "<<toupper(42)<<endl; cout<<"sqrt(4): "<<sqrt(4)<<endl; cout<<"sqrt(-4): "<<sqrt(-4)<<endl; }
  • 5.
  • 6. #include<iostream> using namespace std; int square( int m ); // function prototype //it can be int square( int ); int main() { for ( int x = 1; x <= 10; x++ ) cout << square( x ) << " "; //calling statement x is actual parameter cout << endl; return 0; } // Function definition int square( int y ) // Heading y is Formal Parameter { return y * y; // The return Statement }
  • 7.
  • 8. #include<iostream> using namespace std; int square( int ); // function prototype int main() { for ( int x = 1; x <= 10; x++ ) cout << square( x ) << " "; cout << endl; return 0; } // Function definition int square( int y ) { return y * y; }
  • 9.
  • 10. #include<iostream> using namespace std; int cube( int y ); // function prototype int main() { int x; for ( x = 1; x <= 10; x++ ) cout << cube( x ) << endl; //calling statement x is actual parameter return 0; } // Function definition int cube( int y ) // Heading y is Formal Parameter { return y * y * y; }
  • 11.
  • 12. #include<iostream> using namespace std; int maximum( int, int, int ); // function prototype int main() { int a, b, c; cout << "Enter three integers: "<<endl; cin >> a >> b >> c; // a, b and c below are arguments (actual parameters) to // the maximum function call cout << "Maximum is: " << maximum( a, b, c ) << endl; return 0; } // Function maximum definition // x, y and z below are parameters ( formal parameters) to // the maximum function definition int maximum( int x, int y, int z ) { int max = x; if ( y > max ) max = y; if ( z > max ) max = z; return max; }
  • 13.
  • 15. Programming Example // Program: Largest #include <iostream> using namespace std; double larger(double x, double y); int main() { double num; //variable to hold the current number double max; //variable to hold the larger number int count; //loop control variable cout << "Enter 10 numbers." << endl; cin >> num; //Step 1 max = num; //Step 1 for (count = 1; count < 10; count++) //Step 2 { cin >> num; //Step 2a max = larger(max, num); //Step 2b } cout << "The largest number is " << max<< endl; //Step 3 return 0; }//end main double larger(double x, double y) { if (x >= y) return x; else return y; }
  • 17. #include<iostream> using namespace std; int maximum( int, int, int ); // function prototype int main() { int a, b, c; cout << "Enter three integers: "<<endl; cin >> a >> b >> c; // a, b and c below are arguments (actual parameters) to // the maximum function call cout << "Maximum is: " << maximum( a, b, c ) << endl; return 0; } // Function maximum definition // x, y and z below are parameters ( formal parameters) to // the maximum function definition int maximum( int x, int y, int z ) { int max = x; return 0; if ( y > max ) max = y; if ( z > max ) max = z; return max; }
  • 18.
  • 19. #include<iostream> using namespace std; int maximum( int, int, int ); // function prototype int main() { int a, b, c; return 0; cout << "Enter three integers: "<<endl; cin >> a >> b >> c; // a, b and c below are arguments (actual parameters) to // the maximum function call cout << "Maximum is: " << maximum( a, b, c ) << endl; return 0; } // Function maximum definition // x, y and z below are parameters ( formal parameters) to // the maximum function definition int maximum( int x, int y, int z ) { int max = x; if ( y > max ) max = y; if ( z > max ) max = z; return max; }