SlideShare a Scribd company logo
1 of 20
Function Recap
What is function? A function is a section of a program that performs a specific task . Solving a problem using different functions makes programming much simpler with fewer defects . It’s a solution for a big project that split into small sub project.
Common Type (FUNCTION) Void function Without argument Void unction With Input argument Function with input argument and single result
Void function without argument syntax: void functionname(void) Example: display() draw_circle() draw_triangle() The nearest explantion is printf()
Void function without argument void draw_triangle(void){ introw,space,star; for(row=1;row<=9;row++) {                            for(space=8;space>=row;space--)       { printf("%c",288);                                    };              for (star=1;star<row;star++)        { printf("* ");  }               printf(""); }                                     }
Why void? (most common seen in function without argument) Void is use when the function does not return any value More explanation: The subfunction is called draw_triangle() from the main function but the function prototype is written as void draw_triangle(void)
Void function with input argument syntax:functiontypefunctionname(input) Example: double box(123.45) circumference(5.0) calculate(inum1)
Void function with input argument void box(double num){ printf("***********"); printf("*         *"); printf("*         *"); printf("* %7.2f *",num); printf("*         *"); printf("*         *"); printf("***********"); }
#include<stdio.h> #include<conio.h> void box(double num){ printf("***********"); printf("*         *"); printf("*         *"); printf("* %7.2f *",num); printf("*         *"); printf("*         *"); printf("***********"); } int main(){    box(123.45); getch(); return 0;   }
VOID>> and what is the different between both function shown void box(double num) void draw_triangle(void)
Function with input argument and single result syntax:  functiontypefunctinname(input argument) Example: double circumferencecal(intrads);
Function with input argument and single result #include<stdio.h> #include<conio.h> double circumferencecal(intrads); intmain(){ intrads=5;  double circum;      circum=circumferencecal(rads); printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah %.4lf",rads,circum);    getch();     return 0;     } double circumferencecal(intrads){            double x;            float pi=3.1415;            x=2*pi*rads;            return(x);            }
Returning values ,[object Object]
Return statement is used to return a value to the calling function
Syntax:return (expression) ; ,[object Object],return(iNumber * iNumber);	       return 0;       return (3);       return;       return (10 * i);
Function with multiple arguments Syntax:   functionname(argument1,argument2) Example: circumferencecal(radian,PI);
#include<stdio.h> #include<conio.h> double circumferencecal(intrads,double PI); int main(){ intrads=5;  double circum,PI=3.1415;      circum=circumferencecal(rads,PI); printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah %.4lf",rads,circum); getch();     return 0;     }     double circumferencecal(intrads,double PI){            double x;                      x=2*PI*rads;            return(x);            }
Chotto complicated example #include<stdio.h> #include<conio.h> #include<math.h>  double circumferencecal(intrads,double PI){            double x;            x=2*PI*rads;            return(x);            }  double areacal(intrads,double PI){                       double y;            y=PI*pow(rads,2);            return(y);            } int main(){ intrads=5;  double area,circum,PI=3.1415;          circum=circumferencecal(rads,PI);     area=areacal(rads,PI);   printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah: %.4lfManakalaluasnya pula: %.4lf",rads,circum,area); getch();     return 0;     }
Do and Don’t in Function
GOTO

More Related Content

What's hot (20)

Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
C Structure and Union in C
C Structure and Union in CC Structure and Union in C
C Structure and Union in C
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Mathematics Function in C ,ppt
Mathematics Function in C ,pptMathematics Function in C ,ppt
Mathematics Function in C ,ppt
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
6. function
6. function6. function
6. function
 
Programming in c function
Programming in c functionProgramming in c function
Programming in c function
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
 
9. pointer, pointer & function
9. pointer, pointer & function9. pointer, pointer & function
9. pointer, pointer & function
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
 

Viewers also liked

愛知中小企業家同友会It研究会
愛知中小企業家同友会It研究会愛知中小企業家同友会It研究会
愛知中小企業家同友会It研究会新一 佐藤
 
Mutacions 2010 2011 new
Mutacions 2010 2011 newMutacions 2010 2011 new
Mutacions 2010 2011 newjuanapardo
 
Media Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaMedia Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaadvertisementindia
 
فن استشر والترصيع بالقرميد
فن استشر والترصيع بالقرميدفن استشر والترصيع بالقرميد
فن استشر والترصيع بالقرميدSunflower Al-mahrouqi
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化Akira Tanimoto
 
Master chef 2nd eso 2013
Master chef 2nd eso 2013Master chef 2nd eso 2013
Master chef 2nd eso 2013IES Consaburum
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)alish sha
 
Murid dan alam belajar
Murid dan alam belajarMurid dan alam belajar
Murid dan alam belajarnaginn5024
 
Presentación1
Presentación1Presentación1
Presentación1juanapardo
 
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016Corporación Dijoma
 
Anuncios sexistas
Anuncios sexistasAnuncios sexistas
Anuncios sexistasjuanapardo
 
Storyboard outline
Storyboard outlineStoryboard outline
Storyboard outlineMayci Neal
 
1º manifesto comunista
1º manifesto comunista1º manifesto comunista
1º manifesto comunistaAndréa Dalcin
 
Situación actual de las relaciones entre docentes y estudiantes.
Situación actual de las relaciones entre docentes y estudiantes.Situación actual de las relaciones entre docentes y estudiantes.
Situación actual de las relaciones entre docentes y estudiantes.Leonardo Eras
 

Viewers also liked (20)

愛知中小企業家同友会It研究会
愛知中小企業家同友会It研究会愛知中小企業家同友会It研究会
愛知中小企業家同友会It研究会
 
Mutacions 2010 2011 new
Mutacions 2010 2011 newMutacions 2010 2011 new
Mutacions 2010 2011 new
 
Media Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaMedia Speak on AdvertisementIndia
Media Speak on AdvertisementIndia
 
Element 1 vocabulary cards
Element 1   vocabulary cardsElement 1   vocabulary cards
Element 1 vocabulary cards
 
فن استشر والترصيع بالقرميد
فن استشر والترصيع بالقرميدفن استشر والترصيع بالقرميد
فن استشر والترصيع بالقرميد
 
حصص المشاهدة
حصص المشاهدةحصص المشاهدة
حصص المشاهدة
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化
 
Master chef 2nd eso 2013
Master chef 2nd eso 2013Master chef 2nd eso 2013
Master chef 2nd eso 2013
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Murid dan alam belajar
Murid dan alam belajarMurid dan alam belajar
Murid dan alam belajar
 
Presentación1
Presentación1Presentación1
Presentación1
 
Pop
PopPop
Pop
 
Awsをつかってみた
AwsをつかってみたAwsをつかってみた
Awsをつかってみた
 
MUNDO DAS IDÉIAS
MUNDO DAS IDÉIASMUNDO DAS IDÉIAS
MUNDO DAS IDÉIAS
 
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016
Brochure talleres Lizandra Barbuto y Jhon Croft - Quito Ecuador Abril de 2016
 
Anuncios sexistas
Anuncios sexistasAnuncios sexistas
Anuncios sexistas
 
Storyboard outline
Storyboard outlineStoryboard outline
Storyboard outline
 
γαλιλαIο γαλιλεϊ
γαλιλαIο γαλιλεϊγαλιλαIο γαλιλεϊ
γαλιλαIο γαλιλεϊ
 
1º manifesto comunista
1º manifesto comunista1º manifesto comunista
1º manifesto comunista
 
Situación actual de las relaciones entre docentes y estudiantes.
Situación actual de las relaciones entre docentes y estudiantes.Situación actual de las relaciones entre docentes y estudiantes.
Situación actual de las relaciones entre docentes y estudiantes.
 

Similar to Function recap

Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5alish sha
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...kushwahashivam413
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)hhliu
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
chapter-6 slide.pptx
chapter-6 slide.pptxchapter-6 slide.pptx
chapter-6 slide.pptxcricketreview
 

Similar to Function recap (20)

Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
Functions
FunctionsFunctions
Functions
 
functions
functionsfunctions
functions
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
7 functions
7  functions7  functions
7 functions
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
Functions
FunctionsFunctions
Functions
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
 
Functions
FunctionsFunctions
Functions
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Chapter 7 functions (c)
Chapter 7 functions (c)Chapter 7 functions (c)
Chapter 7 functions (c)
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Array Cont
Array ContArray Cont
Array Cont
 
C programming
C programmingC programming
C programming
 
Function
FunctionFunction
Function
 
chapter-6 slide.pptx
chapter-6 slide.pptxchapter-6 slide.pptx
chapter-6 slide.pptx
 

More from alish sha

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9alish sha
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)alish sha
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation alish sha
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifahalish sha
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifahalish sha
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaboratealish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1alish sha
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Attn list test
Attn list testAttn list test
Attn list testalish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303alish sha
 
Final project
Final projectFinal project
Final projectalish sha
 

More from alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 
Final project
Final projectFinal project
Final project
 

Function recap

  • 2. What is function? A function is a section of a program that performs a specific task . Solving a problem using different functions makes programming much simpler with fewer defects . It’s a solution for a big project that split into small sub project.
  • 3. Common Type (FUNCTION) Void function Without argument Void unction With Input argument Function with input argument and single result
  • 4. Void function without argument syntax: void functionname(void) Example: display() draw_circle() draw_triangle() The nearest explantion is printf()
  • 5. Void function without argument void draw_triangle(void){ introw,space,star; for(row=1;row<=9;row++) { for(space=8;space>=row;space--) { printf("%c",288); }; for (star=1;star<row;star++) { printf("* "); } printf(""); } }
  • 6. Why void? (most common seen in function without argument) Void is use when the function does not return any value More explanation: The subfunction is called draw_triangle() from the main function but the function prototype is written as void draw_triangle(void)
  • 7. Void function with input argument syntax:functiontypefunctionname(input) Example: double box(123.45) circumference(5.0) calculate(inum1)
  • 8. Void function with input argument void box(double num){ printf("***********"); printf("* *"); printf("* *"); printf("* %7.2f *",num); printf("* *"); printf("* *"); printf("***********"); }
  • 9. #include<stdio.h> #include<conio.h> void box(double num){ printf("***********"); printf("* *"); printf("* *"); printf("* %7.2f *",num); printf("* *"); printf("* *"); printf("***********"); } int main(){ box(123.45); getch(); return 0; }
  • 10. VOID>> and what is the different between both function shown void box(double num) void draw_triangle(void)
  • 11. Function with input argument and single result syntax: functiontypefunctinname(input argument) Example: double circumferencecal(intrads);
  • 12. Function with input argument and single result #include<stdio.h> #include<conio.h> double circumferencecal(intrads); intmain(){ intrads=5; double circum; circum=circumferencecal(rads); printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah %.4lf",rads,circum); getch(); return 0; } double circumferencecal(intrads){ double x; float pi=3.1415; x=2*pi*rads; return(x); }
  • 13.
  • 14. Return statement is used to return a value to the calling function
  • 15.
  • 16. Function with multiple arguments Syntax: functionname(argument1,argument2) Example: circumferencecal(radian,PI);
  • 17. #include<stdio.h> #include<conio.h> double circumferencecal(intrads,double PI); int main(){ intrads=5; double circum,PI=3.1415; circum=circumferencecal(rads,PI); printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah %.4lf",rads,circum); getch(); return 0; } double circumferencecal(intrads,double PI){ double x; x=2*PI*rads; return(x); }
  • 18. Chotto complicated example #include<stdio.h> #include<conio.h> #include<math.h> double circumferencecal(intrads,double PI){ double x; x=2*PI*rads; return(x); } double areacal(intrads,double PI){ double y; y=PI*pow(rads,2); return(y); } int main(){ intrads=5; double area,circum,PI=3.1415; circum=circumferencecal(rads,PI); area=areacal(rads,PI); printf("Ukurlilitbagibulatanbagiber-radius-kan %d adalah: %.4lfManakalaluasnya pula: %.4lf",rads,circum,area); getch(); return 0; }
  • 19. Do and Don’t in Function
  • 20. GOTO
  • 21. GO TO Is a function in programming c that allows you to jump according to designation labels Syntax: gotolabel; Just simply means to redirect you to the label located in the coding label: Just simply means to redirect you to the label