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

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

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; }