Definition of function Types of Function Built-in User Defined Catagories of Function No argument No return value Argument but No return value No argument.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

User Defined Functions
Functions Function: The strength of C language is to define and use function. The strength of C language is that C function are easy to define and use.
Spring Semester 2013 Lecture 5
Chapter Five Functions
1 ICS103 Programming in C Lecture 5: Introduction to Functions.
CS 201 Functions Debzani Deb.
Functions in C Computer Programming(1)- 1090CS Manesh T
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
Functions Lecture 4 – Section 2: 9/21/05 Section 4: 9/22/05.
C Functions Programmer-defined functions – Functions written by the programmer to define specific tasks. Functions are invoked by a function call. The.
MAHENDRAN CHAPTER 6. Session Objectives Explain Type of Functions Discuss category of Functions Declaration & Prototypes Explain User Defined Functions.
Reading the data from the input devices and displaying the results on the screen are the two main tasks of any program. To perform these tasks user friendly.
FUNCTIONS. C function can be classified into two categories, namely, library functions and user – defined functions. main is an example of user – defined.
UNIT III. Functions  To divide a big program into a number of relatively smaller and easily manageable subprograms. Each subprogram in C is called a.
PASSING VALUE TO A FUNCTION # CALL BY VALUECALL BY VALUE # CALL BY REFERENCECALL BY REFERENCE STORAGE CLASS # AUTOAUTO # EXTERNALEXTERNAL # STATICSTATIC.
Functions Manesh T 2 Chapter Topics Define Function Standard (Predefined) Functions User-Defined Functions Parts of functions.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
Functions Top-down design Breaking a complex problem into smaller parts that we can understand is a common practice. The process of subdividing a problem.
NA2204.1jcmt CSE 1320 Intermediate Programming C Program Basics Structure of a program and a function type name (parameters) { /* declarations */ statement;
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Functions (1)
FUNCTIONS AND STRUCTURED PROGRAMMING CHAPTER 10. Introduction A c program is composed of at least one function definition, that is the main() function.
FUNCTIONS IN C++. DEFINITION OF A FUNCTION A function is a group of statements that together perform a task. Every C++ program has at least one function,
UniMAP SemI-09/10EKT120: Computer Programming1 Week 5 – Functions (1)
UNIT - 4 FUNCTIONS AND POINTERS. FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
User defined functions
FUNCTIONS A function is a set of instructions that can perform a specific task accordingly. A function is a program that performs a specific task according.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 06 FUNCTIONS 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
1 ICS103 Programming in C Lecture 8: Functions I.
For Loop Lecture No 8. Definition In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
Programming Fundamentals Enumerations and Functions.
Functions Chapter 5. Function A set of instructions that are designed to perform specific task. A complete and independent program. It is executed by.
Functions The fruitful & parameterized functions.
Computer Programming II Lecture 4. Functions - In C++ we use modules to divide the program into smaller and manageable code. These modules are called.
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Week 4 – Functions Coding Functions. Purpose of Coding Functions A function is written to perform a well-defined task; rather than having all logic in.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Advanced Programming in C Passing Parameter to Function.
Chapter 7: Function.
EKT120: Computer Programming
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Functions Chapter 5 CS12 - Computer Programming 1 Chapter 5.
FUNCTIONS.
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Functions in C Mrs. Chitra M. Gaikwad.
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
Buy book Online -
2008/11/05: Lecture 15 CMSC 104, Section 0101 John Y. Park
Tejalal Choudhary “C Programming from Scratch” Function & its types
User Defined Functions
Functions I Creating a programming with small logical units of code.
Functions: Declaration, Definition, Call and return, Scope of variables, Storage classes, Recursive functions, Recursion vs Iteration.
Functions, Part 1 of 3 Topics Using Predefined Functions
A function with one argument
Functions, Part 1 of 3 Topics Using Predefined Functions
CS149D Elements of Computer Science
In C Programming Language
Functions Imran Rashid CTO at ManiWeber Technologies.
Functions, Part 1 of 3 Topics Using Predefined Functions
2008/11/05: Lecture 15 CMSC 104, Section 0101 John Y. Park
Functions I Creating a programming with small logical units of code.
CPS125.
Presentation transcript:

Definition of function Types of Function Built-in User Defined Catagories of Function No argument No return value Argument but No return value No argument with return value argument with return value

A function is a self contained block of code that performs a particular task. C functions can be classified into two categories namely Built-In function and User Defined function BACK

 Built-In Function/Library Function Library function are not required to be written by users. examples of library functions are scanf, printf, sqrt etc User Defined Function User Defined Function User Defined Function have to be developed by the user. main is an example of user defined function. The use of User Defined Function allows a large program into a number of smaller self contained components, each of which has some unique purpose BACK

scanf() printf() getc() putc() A series of Instructions that are to be executed more than once

USER DEFINED FUNCTION : SYNTAX : retu_datatype func_name(arguments) { Body of the function statements; return; } call the function from main() : syntax : func_name(arguments );

#include void hello() //definition { printf(" Welcome to functions\n"); printf("Good Morning\n"); } void main() { clrscr(); printf("Main, Welcome to functions\n"); hello(); //calling printf("Bye"); getch(); } BACK

 NO ARGUMENT NO RETURN VALUES  ARGUMENT BUT NO RETURN VALUES  NO ARGUMENT WITH RETURN VALUES  WITH ARGUMENT WITH RETURN VALUES (Based on Return values and passing Arguments) BACK

/* To perform Addition of two numbers */ /* NO ARGUMENT NO RETURN VALUES */ #include void add();void add() void main(){ {int a,b,c; add(); printf("Enter two numbers\n"); printf("Prg ends"); scanf("%d%d",&a,&b); add(); c=a+b; }printf("The sum is %d\n",c); } BACK

/* To perform Addition of two numbers */ /* WITH ARGUMENT BUT NO RETURN VALUES*/ #include void add(int,int); void main() { int x,y; printf("Enter two number"); scanf("\t\t%d %d",&x,&y); add(x,y); /* Actual Arguments */ } void add(int a,int b) /* Formal Arguments */ { int c=a+b; printf("\t\tThe C Value is %d",c); } BACK

 The return statement is used to return from a function.  It causes execution to return to the point at which the call to the function was made.  The return statement can have a value with it, which it returns to the program

/* To perform Addition of two numbers Without Argument and With Return values */ #include int add(); //declaration void main() { int c; c=add(); /* Return Variable - c */ printf("The sum of two numbers is %d",c); } int add() { int a,b,c; printf("Enter two Numbers="); scanf("%d %d",&a,&b); c=a+b; return(c); } BACK

/* To perform Addition of two numbers With Argument and With Return values */ #include int add(int,int); //Function prototype declaration void main() { int c; printf("Enter two Numbers="); scanf("%d %d",&a,&b); c=add(a,b); /* Actual Arguments */ printf("The sum of two numbers is %d",c); } int add(int x,int y) /* Formal arguments */ { int c; c=x+y; return(c); }

BACK