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

Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
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
ssuser454af01
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
Warui Maina
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
Abdul Samee
 

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

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

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
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
heathfieldcps1
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
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
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
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
 
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.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.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...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.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; }