Buy book Online -

Slides:



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

C Language.
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
Structure.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
CS 201 Functions Debzani Deb.
Topic 4 – Programmer- Defined Functions. CISC 105 – Topic 4 Functions So far, we have only seen programs with one function, main. These programs begin.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
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.
1 CSE1301 Computer Programming Lecture 12 Functions (Part 1)
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,
Engineering Problem Solving with C Fundamental Concepts Chapter 7 Structures.
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.
1 CSE1301 Computer Programming Lecture 13 Functions (Part 1)
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.
Modularity using Functions Chapter 4. Modularity In programming blocks of code often can be "called up" and reused whenever necessary, for example code.
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. 2 Introduction Structure Definitions and Declarations Initializing Structures Operations on Structures Members Structures as Functions Parameters Array.
BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 “Loops”
Functions Chapter 5. Function A set of instructions that are designed to perform specific task. A complete and independent program. It is executed by.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 CSE1301 Computer Programming Lecture 12 Functions (Part 1)
Lecture 10: Structures. Outline Introduction Structure Definitions and declarations Initializing Structures Operations on Structures members Structures.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Computer C programming Chapter 3. CHAPTER 3 Program Looping –The for Statement –Nested for Loops –for Loop Variants –The while Statement –The do Statement.
User-Written Functions
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
CSC215 Lecture Advanced Pointers.
Chapter 10-1: Structure.
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Lecture 7: Repeating a Known Number of Times
FUNCTIONS.
Program to search an element of array using linear search.
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Pointers and Pointer-Based Strings
Visit for more Learning Resources
Functions in C Mrs. Chitra M. Gaikwad.
Arrays in C.
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
11/10/2018.
Buy book Online -
Tejalal Choudhary “C Programming from Scratch” Function & its types
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Functions I Creating a programming with small logical units of code.
6 Chapter Functions.
CSI 121 Structured Programming Language Lecture 13 Functions (Part 1)
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Arrays, Part 1 of 2 Topics Definition of a Data Structure
In C Programming Language
Pointers and Pointer-Based Strings
FUNCTION.
Arrays.
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Course Outcomes of Programming In C (PIC) (17212, C203):
Functions I Creating a programming with small logical units of code.
CPS125.
Storage Classes.
Visit for more Learning Resources
Presentation transcript:

Buy book Online - www.icebreakerspublications.com

Func tions Definition : The function is sub program or set of instructions written to do a particular task. We have already used functions like printf() , scanf() , strlen() etc. Every C program can be thought of as a collection of these functions. There are basically two needs of function: 1. Writing functions avoids rewriting the same code again and again. 2. Using function it becomes easier to write a program. Buy book Online - www.icebreakerspublications.com

Example : Function #include<stdio.h> void Hello(); //1. function declaration int main() { Hello(); printf(“I a return 0; } void Hell { printf(“Hello World } Output: Hello World I am back Buy book Online - www.icebreakerspublications.com

Types of function call Function call is of two types 1. Call by value 2. Call by reference Call by value: when we call function by passing normal values (or variable), the function call is called as call by value. We have already seen an example of this type above. Call by reference: when we call function by passing reference of variable or values, the function call is called as call by reference. Buy book Online - www.icebreakerspublications.com

Cal l by v alue #include<stdio.h> int add (int , int); //1. function declaration int main() { int y y=Add(5,6); // 2. function call (5,6) are actual argument printf(“addition = %d” , y); return 0; } int add (int x, int y) { // 3. function definition x &y are formal argument int result; result=x+y; return result; } output: addition =11

Return Values #include<stdio.h> int add (int , int); //1. function declaration int main() { int y=Add(5,6); // 2. function call (5,6) are actual argument printf(“addition = %d” , y); return 0; } int add (int x, int y) { // 3. function definition return (x+y); // return (expression) } Buy book Online - www.icebreakerspublications.com

Recursion main(); //main() is called again in its own function body Definition : In C, it is possible for the functions to call themselves. A function is called ‘recursive’ if a statement within the body of a function calls the same function. Output: #include<stdio.h> #include<conio.h> Hello Hello int main() { Hello Hello printf(“\nHello”)͖ main(); //main() is called again in its own function body getch(); return 0; Note: run indefinitely as no } break condition Buy book Online - www.icebreakerspublications.com

St r u c t u re A simple variable can hold a single element of any data type. Array allows user to store multiplevalues of same data type. Structure allows user to store multiple values of different data type. Buy book Online - www.icebreakerspublications.com

Example : Structure member #include<stdio.h> int main() struct keyword structure name { st { int pages ; member //structure declaration flo } ; terminating semicolon struct book b1; // sets aside space in memory printf ( "\n Enter no. of pages & price of book\n" ) ; scanf ( " %d %f", &b1.pages, &b1.price ) ; //Accessing member of structure printf ( "\n You entered : " ) ; printf ( "\n %c %f %d", b1.pages, b1.price) ; } //Accessing member of structure Output: Enter no. of pages & price of book 120 200 You entered 120 200

End of chapter