SlideShare a Scribd company logo
1 of 14
Learn Function
The Hard Way
Hello!
I am Iftekhar Mohammad
Just another noob :v
and Gintama Fan :3
Function
Who works from the shadow
“
“Functions are "self contained" modules of
code that accomplish a specific task.
Functions usually "take in" data, process it,
and "return" a result. Once a function is
written, it can be used over and over and
over again. Functions can be "called" from
the inside of other functions.”
What we will do:
◎Talk about Function
◎Compare functions (in programming) with
functions (in math)
◎See some examples
◎Try to establish that definition
Function In Math….
A block of equation who..
◎ Takes value(s)
◎ Processes the
equation with that
value(s)
◎ Finds a value(s)
◎ Gives us that value(s)
Example: F(x)=2x+1
◎F(3)=2x+1
◎F(3)=2*3+1
◎F(3)=7
◎F(x)=7 (where x=3)
Function In Programming….
A block of Code who…
◎ Takes value(s)
◎ Processes the
statement(s) with
that value(s)
◎ Finds a output
◎ Returns us that
output
Example: int add(int a, int b){
int result;
result=a+b;
return result;
}
◎ add(2,3); //also can take variables
◎ result= 2+3; //in compiler this
happens
◎ result=5; //in compiler this happens
◎ return result;//returns 5
Math:
◎ There is a function f(x)//
◎ F(x)=2x+1
◎ F(3)=2x+1
◎ F(3)=2*3+1
◎ F(3)=7
◎ F(x)=7 (where x=3)
Lets see them side by side:
Programming:
◎ int add(int a, int b);
◎ int add(int a, int b){
int result;
result=a+b;
return result;
}
◎ add(2,3);
◎ result=2+3;
◎ result=5;
◎ Return result;
Math:
◎ There is a function f(x)//declaration
◎ F(x)=2x+1 //definition
◎ F(3)=2x+1//calling
◎ F(3)=2*3+1 //processing
◎ F(3)=7 //output
◎ F(x)=7 (where x=3)//return output
Lets see them side by side more deeply:
Programming:
◎ int add(int a, int b); //declaration
◎ int add(int a, int b){//definition
int result;
result=a+b;
return result;
}
◎ add(2,3); //calling
◎ result=2+3; //processing
◎ result=5; //output
◎ Return result; //return output
So……..
Both programming and
math function matches the
definition.
Functions:
1. accomplish a specific
task
2. take in data
3. process data
4. return a result
5. can be used over and
over again
6. can be called
Examples:
◎Write A function that squares the input. Like
if I give 2 it will return 4:
#include<stdio.h>
float square ( float x );
int main( )
{
float m, n ;
printf ( "Enter some number for finding square: n");
scanf ( "%f", &m ) ;
n = square ( m ) ;
printf ( “ n Square of the given number %f is %f",m,n );
}
float square ( float x ) {
float p ;
p = x * x ;
return p ;
}
Examples:
◎Write A function that divides a input with
another input. Like if I give 4 and 2 it will return 2:
#include <stdio.h>
int divide( int x, int y );
int main() {
int x, y;
printf( "Please input two numbers to be divided:");
scanf( "%d %d", &x , &y );
printf( "The Division of your two numbers is %dn", divide( x, y ) );
}
int divide(int x, int y)
{
return x / y;
}
Problems:
Try to solve the followings:
1. Write a function find the modulus of two input.
2. Write a function to solve the equation: 2x+5y-3.
3. Write a function to solve the equation: x2+2xy+y2
4. Write a function to solve the equation: x2-2xy+y2
5. Write a function to the find the distance a car will travel when
initial velocity = x ms-1, acceleration= y ms-2 and time = t second.
Thanks!
Any questions?

More Related Content

What's hot (20)

Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C ProgrammingLecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
 
Multidimensional arrays in C++
Multidimensional arrays in C++Multidimensional arrays in C++
Multidimensional arrays in C++
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started
 
Arrays
ArraysArrays
Arrays
 
Lecture 17 - Strings
Lecture 17 - StringsLecture 17 - Strings
Lecture 17 - Strings
 
Chap 9(functions)
Chap 9(functions)Chap 9(functions)
Chap 9(functions)
 
Lecture 7- Operators and Expressions
Lecture 7- Operators and Expressions Lecture 7- Operators and Expressions
Lecture 7- Operators and Expressions
 
Functions (Computer programming and utilization)
Functions (Computer programming and utilization)Functions (Computer programming and utilization)
Functions (Computer programming and utilization)
 
Arrays and Pointers
Arrays and PointersArrays and Pointers
Arrays and Pointers
 
C++ lecture 03
C++   lecture 03C++   lecture 03
C++ lecture 03
 
Arrays
ArraysArrays
Arrays
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 

Viewers also liked

Atmospheric Pressure Chemical Ionization
Atmospheric Pressure Chemical IonizationAtmospheric Pressure Chemical Ionization
Atmospheric Pressure Chemical IonizationVISHAL THAKUR
 
Atmospheric Pressure Ionization
Atmospheric Pressure IonizationAtmospheric Pressure Ionization
Atmospheric Pressure IonizationVinitha Nair
 
Chemical ionization
Chemical ionizationChemical ionization
Chemical ionizationAarif Khan
 
Lcms gcms and its applications
Lcms gcms and its applicationsLcms gcms and its applications
Lcms gcms and its applicationsNihal Calicut
 
Chromatography lc ms
Chromatography lc msChromatography lc ms
Chromatography lc msmohammed rida
 
Ionizaion Techniques - Mass Spectroscopy
Ionizaion Techniques - Mass SpectroscopyIonizaion Techniques - Mass Spectroscopy
Ionizaion Techniques - Mass SpectroscopySuraj Choudhary
 
Radiation detectors
Radiation detectorsRadiation detectors
Radiation detectorsjmocherman
 
Ionization chamber
Ionization chamberIonization chamber
Ionization chamberAnas Yess
 
Liquid chromatography and mass spectrometry.(LCMS)
Liquid chromatography and mass spectrometry.(LCMS)Liquid chromatography and mass spectrometry.(LCMS)
Liquid chromatography and mass spectrometry.(LCMS)Saptarshi Das
 
Mass spectrometry(Ionization Techniques) by Ashutosh Panke
Mass spectrometry(Ionization Techniques) by Ashutosh PankeMass spectrometry(Ionization Techniques) by Ashutosh Panke
Mass spectrometry(Ionization Techniques) by Ashutosh PankeAshutosh Panke
 
Mass spectrometry basic principles
Mass spectrometry basic principlesMass spectrometry basic principles
Mass spectrometry basic principlesRania Elsharkawy
 

Viewers also liked (13)

Atmospheric Pressure Chemical Ionization
Atmospheric Pressure Chemical IonizationAtmospheric Pressure Chemical Ionization
Atmospheric Pressure Chemical Ionization
 
Atmospheric Pressure Ionization
Atmospheric Pressure IonizationAtmospheric Pressure Ionization
Atmospheric Pressure Ionization
 
Chemical ionization
Chemical ionizationChemical ionization
Chemical ionization
 
Lcms gcms and its applications
Lcms gcms and its applicationsLcms gcms and its applications
Lcms gcms and its applications
 
Chromatography lc ms
Chromatography lc msChromatography lc ms
Chromatography lc ms
 
Ionizaion Techniques - Mass Spectroscopy
Ionizaion Techniques - Mass SpectroscopyIonizaion Techniques - Mass Spectroscopy
Ionizaion Techniques - Mass Spectroscopy
 
Radiation detectors
Radiation detectorsRadiation detectors
Radiation detectors
 
Ionization chamber
Ionization chamberIonization chamber
Ionization chamber
 
Liquid chromatography and mass spectrometry.(LCMS)
Liquid chromatography and mass spectrometry.(LCMS)Liquid chromatography and mass spectrometry.(LCMS)
Liquid chromatography and mass spectrometry.(LCMS)
 
Mass spectrometry(Ionization Techniques) by Ashutosh Panke
Mass spectrometry(Ionization Techniques) by Ashutosh PankeMass spectrometry(Ionization Techniques) by Ashutosh Panke
Mass spectrometry(Ionization Techniques) by Ashutosh Panke
 
Radiation detectors
Radiation detectorsRadiation detectors
Radiation detectors
 
Mass spectrometry basic principles
Mass spectrometry basic principlesMass spectrometry basic principles
Mass spectrometry basic principles
 
Mass spectrometry
Mass spectrometryMass spectrometry
Mass spectrometry
 

Similar to Learn Function The Hard Way

Similar to Learn Function The Hard Way (20)

6. function
6. function6. function
6. function
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
 
C function
C functionC function
C function
 
functions
functionsfunctions
functions
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
 
CHAPTER 6
CHAPTER 6CHAPTER 6
CHAPTER 6
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)
 
Functions
FunctionsFunctions
Functions
 
Function
FunctionFunction
Function
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Unit 3 (1)
Unit 3 (1)Unit 3 (1)
Unit 3 (1)
 
Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / Overview
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
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
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
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
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
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
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
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
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
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
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
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
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 

Learn Function The Hard Way

  • 2. Hello! I am Iftekhar Mohammad Just another noob :v and Gintama Fan :3
  • 4. “ “Functions are "self contained" modules of code that accomplish a specific task. Functions usually "take in" data, process it, and "return" a result. Once a function is written, it can be used over and over and over again. Functions can be "called" from the inside of other functions.”
  • 5. What we will do: ◎Talk about Function ◎Compare functions (in programming) with functions (in math) ◎See some examples ◎Try to establish that definition
  • 6. Function In Math…. A block of equation who.. ◎ Takes value(s) ◎ Processes the equation with that value(s) ◎ Finds a value(s) ◎ Gives us that value(s) Example: F(x)=2x+1 ◎F(3)=2x+1 ◎F(3)=2*3+1 ◎F(3)=7 ◎F(x)=7 (where x=3)
  • 7. Function In Programming…. A block of Code who… ◎ Takes value(s) ◎ Processes the statement(s) with that value(s) ◎ Finds a output ◎ Returns us that output Example: int add(int a, int b){ int result; result=a+b; return result; } ◎ add(2,3); //also can take variables ◎ result= 2+3; //in compiler this happens ◎ result=5; //in compiler this happens ◎ return result;//returns 5
  • 8. Math: ◎ There is a function f(x)// ◎ F(x)=2x+1 ◎ F(3)=2x+1 ◎ F(3)=2*3+1 ◎ F(3)=7 ◎ F(x)=7 (where x=3) Lets see them side by side: Programming: ◎ int add(int a, int b); ◎ int add(int a, int b){ int result; result=a+b; return result; } ◎ add(2,3); ◎ result=2+3; ◎ result=5; ◎ Return result;
  • 9. Math: ◎ There is a function f(x)//declaration ◎ F(x)=2x+1 //definition ◎ F(3)=2x+1//calling ◎ F(3)=2*3+1 //processing ◎ F(3)=7 //output ◎ F(x)=7 (where x=3)//return output Lets see them side by side more deeply: Programming: ◎ int add(int a, int b); //declaration ◎ int add(int a, int b){//definition int result; result=a+b; return result; } ◎ add(2,3); //calling ◎ result=2+3; //processing ◎ result=5; //output ◎ Return result; //return output
  • 10. So…….. Both programming and math function matches the definition. Functions: 1. accomplish a specific task 2. take in data 3. process data 4. return a result 5. can be used over and over again 6. can be called
  • 11. Examples: ◎Write A function that squares the input. Like if I give 2 it will return 4: #include<stdio.h> float square ( float x ); int main( ) { float m, n ; printf ( "Enter some number for finding square: n"); scanf ( "%f", &m ) ; n = square ( m ) ; printf ( “ n Square of the given number %f is %f",m,n ); } float square ( float x ) { float p ; p = x * x ; return p ; }
  • 12. Examples: ◎Write A function that divides a input with another input. Like if I give 4 and 2 it will return 2: #include <stdio.h> int divide( int x, int y ); int main() { int x, y; printf( "Please input two numbers to be divided:"); scanf( "%d %d", &x , &y ); printf( "The Division of your two numbers is %dn", divide( x, y ) ); } int divide(int x, int y) { return x / y; }
  • 13. Problems: Try to solve the followings: 1. Write a function find the modulus of two input. 2. Write a function to solve the equation: 2x+5y-3. 3. Write a function to solve the equation: x2+2xy+y2 4. Write a function to solve the equation: x2-2xy+y2 5. Write a function to the find the distance a car will travel when initial velocity = x ms-1, acceleration= y ms-2 and time = t second.