SlideShare a Scribd company logo
#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;
}
ch6_additional.ppt
ch6_additional.ppt
#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;
}
ch6_additional.ppt
#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
}
ch6_additional.ppt
#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;
}
ch6_additional.ppt
#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;
}
ch6_additional.ppt
#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;
}
ch6_additional.ppt
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;
}
ch6_additional.ppt
#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

PPTX
C++ programming function
PPT
Lecture#6 functions in c++
PPTX
functions of C++
PPTX
Session06 functions
PPTX
Cs1123 8 functions
PPTX
C++_Functions_Presentation of CS eve.pptx
PDF
how to reuse code
C++ programming function
Lecture#6 functions in c++
functions of C++
Session06 functions
Cs1123 8 functions
C++_Functions_Presentation of CS eve.pptx
how to reuse code

Similar to ch6_additional.ppt (20)

PDF
6. functions
PDF
C++ Nested loops, matrix and fuctions.pdf
PPTX
Part 3-functions1-120315220356-phpapp01
PPT
Inbuilt Functions in C++ computer language.ppt
PPTX
C++ Programm.pptx
PDF
C++ Programming - 14th Study
PDF
C++ L05-Functions
PPT
Cpphtp4 ppt 03
PDF
Part I Write a program that uses a function that takes in two integ.pdf
PDF
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
PPT
cpphtp4_PPT_03.ppt
PPT
Lecture05
PPTX
CPP Homework Help
PPTX
Fundamental of programming Fundamental of programming
DOCX
C++ file
DOCX
C++ file
PPTX
Silde of the cse fundamentals a deep analysis
PPTX
Example Programs of CPP programs ch 1.pptx
PPTX
Function C++
PDF
10 template code program
6. functions
C++ Nested loops, matrix and fuctions.pdf
Part 3-functions1-120315220356-phpapp01
Inbuilt Functions in C++ computer language.ppt
C++ Programm.pptx
C++ Programming - 14th Study
C++ L05-Functions
Cpphtp4 ppt 03
Part I Write a program that uses a function that takes in two integ.pdf
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
cpphtp4_PPT_03.ppt
Lecture05
CPP Homework Help
Fundamental of programming Fundamental of programming
C++ file
C++ file
Silde of the cse fundamentals a deep analysis
Example Programs of CPP programs ch 1.pptx
Function C++
10 template code program

More from LokeshK66 (9)

PPTX
Iot application in smart cities .pptx
PPTX
building mat.pptx
PPT
9781423902096_PPT_ch07.ppt
PPT
9781423902096_PPT_ch08.ppt
PPT
9781423902096_PPT_ch09.ppt
PPT
ch4_additional.ppt
PPT
ch5_additional.ppt
PPT
ch9_additional.ppt
PPT
SQLSecurity.ppt
Iot application in smart cities .pptx
building mat.pptx
9781423902096_PPT_ch07.ppt
9781423902096_PPT_ch08.ppt
9781423902096_PPT_ch09.ppt
ch4_additional.ppt
ch5_additional.ppt
ch9_additional.ppt
SQLSecurity.ppt

Recently uploaded (20)

PPTX
Lesson notes of climatology university.
PDF
Pre independence Education in Inndia.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Classroom Observation Tools for Teachers
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Insiders guide to clinical Medicine.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Lesson notes of climatology university.
Pre independence Education in Inndia.pdf
VCE English Exam - Section C Student Revision Booklet
Classroom Observation Tools for Teachers
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Insiders guide to clinical Medicine.pdf
GDM (1) (1).pptx small presentation for students
FourierSeries-QuestionsWithAnswers(Part-A).pdf
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O5-L3 Freight Transport Ops (International) V1.pdf
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
Module 4: Burden of Disease Tutorial Slides S2 2025
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.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; }
  • 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; }
  • 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 }
  • 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; }
  • 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; }
  • 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; }
  • 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; }
  • 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; }