Computer Programming 6th Week Functions (Function definition, function calls),

Size: px
Start display at page:

Download "Computer Programming 6th Week Functions (Function definition, function calls),"

Transcription

1 Computer Programming 6th Week Functions (Function definition, function calls), Hazırlayan Asst. Prof. Dr. Tansu Filik

2 Computer Programming Previously on Bil-200 loops (do-while, for), Arrays, array operations, C libraries

3 Computer Programming C Libraries C Liabraries "math.h", "stdlib.h", "string.h"

4 Computer Programming C Libraries The main C language only consists of expressions and grammar rules. C, itself, has NO built in function! Most C compilers come with the standard libraries containing several useful functions. In order to be able to use these functions, you must use #include directive to include the associated library containing the useful function.

5 Computer Programming C Libraries Function Libraries <stdio.h> - printf(), fprintf(), scanf(), fscanf(), fopen(), putchar(), getchar(),... <math.h> - pow(), sqrt(), fabs()... <ctype.h> - toupper(), tolower(), isalpha(), isdigit(),... <stdlib.h> - rand(), srand(), exit(),...

6 Introduction to Programming Languages C Libraries Function Libraries : math.h Many mathematical function (prototypes) exist here. fabs (x) : absolute value of float x sqrt (x) : square root of x exp (x) : e to the power x (e = ) log (x) : ln x log10 (x) : base-10 logarithm pow(x, y) : x to the power y sin (x) : sine (radians) cos (x) : cosine (radians) tan (x) : tangent fmod (a, b) : remainder of a/b ceil (x) : least integer >= x floor (x) : greatest integer <= x

7 Introduction to Programming Languages C Libraries Function Libraries : stdlib.h exit(val) : used for terminating program. if (fp == NULL) exit(1); /* if file cannot open, quit*/ rand(void) : generates a random number for(i=0; i < 100; ++i) /* 100 random numbers*/ printf("%d ", rand()); srand(value) : seed for the randomizer srand(100); /* starting point of random sequence*/

8 Introduction to Programming Languages C Libraries Function Libraries : time.h time(null): Numbe of seconds passed since 01/01/1970. int secs; secs = time(null);

9 Introduction to Programming Languages C Libraries Example: Approximate pi value Pi is a very commonly used constant in mathematical expressions. This number has infinite decimal points. Special applications require as many of these decimals as possible. Simple applications may be OK with 22/7. In the following example, we will see how near to pi the value 22/7 is. In C, asin(1) is approximately equal to pi.

10 Approximate value of pi #include <stdio.h> #include <math.h> int main(void) double pi, yak, hata; asin, is the arc-sine function. pi = 2 * asin(1); /* realistic pi value*/ yak = (double) 22 / 7; /* approximate pi */ hata = fabs(yak pi) / pi; /* find error */ printf("pi = %.15f\n", pi); /* write result */ printf("yaklaşık = %.15f\n", yak); printf("hata = %.5f", hata * 100); return 0;

11 pi = yaklaşık = hata = Press any key to continue

12 time(null) Gives number of seconds since 01/01/1970 At 13:40 on 17/11/2015, its value was. zaman: #include<stdio.h> #include<time.h> void main() int t; t = time(null); printf("zaman: %d \n", t);

13 time(null) Before using you should write: #include <time.h> Usage: int t; t = time(null); Since each time instant is different, it is a good randomization seed.

14 Clock: tik-tak #include <stdio.h> #include <time.h> void main(void) int i, t; for(i=0; i <= 10; ++i) /* just for 10 sec */ t = time(null) + 1; /* t next sec */ while (time(null) < t); /* wait */ printf("tik\n"); /* write tik */ t = time(null) + 1; /* wait 1 sac */ while(time(null) < t); /* wait */ printf("tak\n"); /* write tak */

15 Introduction to Programming Languages Functions Functions The modules that are written by the programmer

16 Introduction to Programming Languages Functions Function Calls Calling a function means returning the value of a named list of commands that do a specific task. We may call functions that we write ourselves. We may call functions that already exist in the standard C library. Ex: printf, scanf, sqrt

17 Introduction to Programming Languages Functions Example Write a program which obtains and prints out the square-root of an entered number. #include <stdio.h> #include <math.h> /* Ekrandan girilen bir sayının karekökünü yazar. */ int main() float x, sonuc; printf("bir sayi giriniz"); scanf("%f", &x); sonuc = sqrt(x); printf("sonuc = %f", sonuc); return 0;

18 Introduction to Programming Languages Functions Until now, we wrote our program using a single function: main(). The sytax was: void main ( ) /* definitions */ /* expressions */ The term void indicates that this function returns NOTHING.

19 Introduction to Programming Languages Functions The () parantheses indicate that main is a function. Inside these parantheses, you send parameters to the function. For this particular case, we do not send anything to the function, so the parantheses are empty. Normally, functions require a list of parameters to be sent to them for processing and generating a result. That result may be returned to the function calling place.

20 Introduction to Programming Languages Functions A function can be written is three steps: 1. Function prototype declaration 2. The function itself (declaration + commands inside) 3. The expression that calls the function.

21 Introduction to Programming Languages Functions 1. Function prototypes Compilers trace the program from top to bottom. If you write a program which tries to use your functions, the compiler needs to know how the function is called. The prototypes are listed at the top to show the parametric interface of functions. void, char, int, float, double semicolon

22 Introduction to Programming Languages Functions 1. Function prototypes: Parameters Parameter list is a list of types that will enter to the function. float toplam(int a,int b,int c) ;

23 Introduction to Programming Languages Functions 2. Function definition In the real declaration of function, do not put ; at the end of first line. float toplam(int a,int b, int c) Here, the function toplam takes three variables: a, b and c. The return type is float. a, b and c values are sent by the place where the function is called.

24 Introduction to Programming Languages Functions 2. Function definition Function definition consists of a declaration line similar to the prototype, followed by a list of commands bounded by curly parantheses: float toplam( int a, int b, int c) float t; t = a + b + c ; return t; Note: The function returns a value using the return keyword. If the return type is void, you do not need to use a return line.

25 Introduction to Programming Languages Functions 2. Function definition float toplam( int a, int b, int c) float t; t = a + b + c ; return t; The variables a, b and c are valid only inside the function toplam. The variable t is also valid only inside the function, and its memory location is freed when the function finished.

26 Introduction to Programming Languages Functions 3. Function calls While calling a function, it must be compatible with the prototype and the return type. The sent parameters must also be compatible with the types. You may send proper variables, expressions, or values to a function. For this case: deger = toplam( i, j, k ) ; or deger = toplam( 5, x, 2.7 ) ;

27 Introduction to Programming Languages Functions 3. Function calls Inside the main() function, the function toplam() is called. In that case, the parameter values are copied into the parameter list variables of the function.

28 Introduction to Programming Languages Functions 3. Function calls main() data memory i 12 j 25 copied copied toplam() data memory a b 45 k copied c 45

29 #include<stdio.h> void func1(void); int func2(int n, char ch); void main(void) int i=1,j=2; char ch= 0 ; printf( %d %d\n,i,j); func1(); j=func2(i,ch); printf( %d %d\n,i,j); void func1(void) printf( selam!\n );... FUNCTIONS- review Prototype declarations. Before using in main or other functions, declare their names like this. Their bodies will be written later. Calling a void-type function. Result is not assigned to anything. There is no input (void). Function generates an int type output. Therefore, its output can be assigned to some variable. Inputs are an int and a char. One of the functions whose prototype was declared. It is fully defined here. The I/O style of this and its prototype are compatible.

30 ... int func2(int x, char y) int z; printf( Basta: x=%d, y=%c\n,x,y); z=x*y; printf( Simdi: z=%d\n,z); return z; Since function generates an int......an int variable is declared inside......and a value is assigned to it......and variable is returned (function value produced). /* As a result, this function adopts a value at the place where it is called. */

31 Introduction to Programming Languages Functions Prototypes are necessary if you plant to write functions at the end of the program. In this way, you can safely use functions within functions. If you write functions before main, or before other functions which call them, you do not need to use prototypes. In this case, if a function (a) is used in function (b), then (a) must be written on top of (b).

32 Introduction to Programming Languages Functions General function syntax

33 void face(void) printf( :-) ); void next_line(void) printf( \n ); void faces(int n) if(i<=0) return; else for(i=1;i<=n;i++) face(); next_line(); void main(void) faces(3); faces(2); faces(1); :-):-):-) :-):-) :-)

34 Introduction to Programming Languages Functions Exercise: function factorial() Write a function to evaluate the factorial of a number. For parameters less than zero, the return value will be 0. For zero and one, the return value is 1, for larger numbers, use a loop to evaluate. In the main function, write a loop to evaluate factorials of numbers from 0 to 10, and print on the screen. Do not forget to write the prototype.

35 Introduction to Programming Languages Functions Exercise: factorial program #include <stdio.h> int factorial( int x); for (i = 0 ; i < 10 ; i++ ) printf("%d! = %d\n", i, factorial(i)); void main() int i;

36 Introduction to Programming Languages Functions Exercise: factorial program int factorial ( int x ) int f = 1, k; for ( k = 2 ; k <= x ; k++ ) f *= k ; return f ; if ( x < 0 ) return 0; else if ( x==0 x==1 ) return 1; /* Return 1 for 0 or 1 */

37 Introduction to Programming Languages Functions Exercise: Write a function which takes two parameters and returns the factorial of the difference. Function must start as: int factorial_diff(int a, int b) This function may call the function factorial() which was previously implemented. Do not forget to write the prototypes.

38 Introduction to Programming Languages Functions Class Exercise: Main Program #include <...> printf("fark= %d\n", factorial_diff(a,b)); /* prototype */ int factorial_diff(int a, int b); void main() int a,b; printf("farkın alinacagi sayilari girin: "); scanf("%d %d", &a, &b);

39 Introduction to Programming Languages Functions - Phylosophy For early programming languages, procedural structure was a great improvement... Instead of a single big and nasty program; Intelligible and easily written blocks are preferable. Then, which parts should be made a function? How do we decide on the structure? How do functions communicate with each other and with main? There must be an interface standard.

40 Introduction to Programming Languages Recursion Some mathematical problems and graph theoretical questions are inherently recursive : n! = n * (n-1)!... (n-1)! =(n-1) * (n-2)! Fibonacci series: 0, 1, 1, 2, 3, 5, 8... fib( n ) = fib( n - 1 ) + fib( n 2 ) In this case, the function must call itself! (n-2)! = (n-2)*(n-3)!

41 long fibonacci( long n ) if (n == 0 n == 1) /* en alt */ return n; else return fibonacci( n - 1) + fibonacci( n 2 ); f( 3 ) return f( 2 ) + f( 1 ) return f( 1 ) + f( 0 ) return 1 return 1 return 0

42 long fibonacci( long n ) printf("%d\n",n); if (n == 0 n == 1) /* en alt */ return n; else return fibonacci( n - 1) + fibonacci( n 2 ); f( 3 ) return f( 2 ) + f( 1 ) return f( 1 ) + f( 0 ) return return 1 return 0

43 int factorial(int a) if(a<0) fprintf(stderr, Gecersiz sayi\n ); return; else if ((a==0) (a==1)) return 1; else return (a*factorial(a-1));

44 Exercise: tanh 1 x x x x x Evaluate the above expression until the added numbers become smaller than a determined threshold.

45 void a(void) int x=10; printf( %d\n,x); x++; printf( %d\n,x); void b(void) static int x=10; printf( %d\n,x); x++; printf( %d\n,x); The value of this variable is assigned to 10 for the first call of function. Then, each time the function is called, the previous value is remembered. void main(void) a(); a(); a(); a(); b(); b(); b(); b(); a: b:

46 Exercises: What's wrong with the following listing? #include <stdio.h> void print_msg( void ); main() print_msg( "This is a message to print" ); return 0; void print_msg( void ) puts( "This is a message to print" ); return 0; What's wrong with the following function definition? int twice(int y); return (2 * y);

47 The values of local variables are unknown to outside the function. Different functions may have local variables with same names. Their values have nothing to do with other functions variables. The variables (parameters) that are sent to the function can change their values inside the function. BUT!!! The variable which is inside the function call does not change. The function makes a copy of the variable, and uses it. It does not use the original variable.

48 !! Example!! Write a function which swaps the values of its two parameters: int a=6, b=4; printf("%d %d\n", a, b); degistir(a, b); printf("%d %d\n", a, b); The first printf should write "6 4", the next should "4 6".

49 void degistir ( int a, int b ) int gecici; Solution (?) gecici = a; a = b; b = gecici; a and b are local variables, specific to the function only. The function is unable to change the values.

50 Why doesn t it work? Because you may send parameters to functions in two ways: by value by reference By value: While calling function, a copy of the variable value is sent. The original variable is not sent. By reference: While calling function, the real address of the variable is sent to the function. Inside the function, the values at that address can be changed. So the variable value also changes! (Remember scanf())

51 Function calls Remember function: toplam(). When it is called, the loal variables work, and when the function finishes, the local variables are lost. So how can we send parameters by reference? By address-pointer syntax. main() memory area i 12 j 25? copied copied toplam() memory area a 12 b 25

52 Two-way communication with functions #include <stdio.h> void swap(int *a,int *b); void main() int i = 1, j = 2; &i and &j, are memory locations of i and j. We send addresses to the swap() function. swap(&i, &j); void swap(int *a, int *b) int t; a and b are address (pointer) variables. t = *a; *a = *b; *b = t; By writing *a and *b, we can rach to the values in the given address.

53 Sending addresses to functions main() memory area &i toplam() memory area a 12 i 100 &j 100 b j This is the memory location of variable j

54 We already use such functions Remember scanf(); fscanf(); fopen(); etc... Think of function scanf(). What is critical here? Why do we send addresses of variables: scanf( %d, &i); Because we want to change the value of variable i. Why do we use scanf( %s, str);? We have not seen yet, but str is already an address!

55 scanf(&num) illustration &num &num 2 byte Read from keyboard: (Assume 10 is entered) 0 A

56 If you send the variable with & (address) sign - just like doing in scanf() we can change its value inside the function by writing thing to its memory location. Since the memory location corresponds to the container of the original variable, its value automatically changes.. So, what is the syntax (format) of a function that accepts addresses? We use *variable notation.

57 void my_func(int *num) This part is just like other functions. The argument listing part is different. int *num; is a variable whose address is num. We call the above function as: my_func(&i);

58 Example: If we want to print out the value of the parameter which was sent: void my_func(int *num) printf("\n%d", num); printf("\n%d\n", *num); void main(void) int *num; int i = 1; my_func(&i);

59 void my_func(int *num) printf( %d\n,*num); *num = 2; printf( %d\n,*num); void main(void) int a=3; printf( %d\n,a); my_func(&a); printf( %d\n,a); This is the int variable; num is not int! If you call the function like this (with address)...then the function argument must be declared with * (a pointer) indicator.

60 void degis(int *n, int *m) int k; printf( Degismeden once, n=%d, m=%d,,*n,*m); k=*n; *n=*m; *m=*k; printf( Degistikten sonra, n=%d, m=%d,,*n,*m); void main(void) int n1=10,n2=20; printf( Fonksiyon oncesi n1=%d, n2=%d,n1,n2); degis(&n1,&n2); printf( Fonksiyon sonrasi n1=%d, n2=%d,n1,n2);

61 = &n1 = n *n=10 &n2 m *m=

62 If you want to use address/pointer convention, but keep the value unchanged, then use const int *const num; /* for instance... */

63 Class Exercise Write a function which reads three float variables from the user, and returns them. The name would be: read_return(). The main program must be like: #include <stdio.h> main() float a, b, c; read_return(&a, &b, &c); printf( The numbers: %f %f %f\n",a,b,c);

64 Alternative uses void getnum(int *num) int k; printf( bir sayi girin: ); scanf( %d,&k); num=k; void getnum(int *num) printf( bir sayi girin: ); scanf( %d,num); void main(void) int k; getnum(&k); scanf( %d,k);

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Computer Programming Previously on Bil 200 Midterm Exam - 1 Midterm Exam - 1 126 students Curve: 49,78 Computer Programming Arrays Arrays List of variables: [ ] Computer Programming

More information

Computer Programming: 7th Week Functions, Recursive Functions, Introduction to Pointers

Computer Programming: 7th Week Functions, Recursive Functions, Introduction to Pointers Computer Programming: 7th Week Functions, Recursive Functions, Introduction to Pointers Hazırlayan Asst. Prof. Dr. Tansu Filik Introduction to Programming Languages Previously on Bil-200 Functions: Function

More information

Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries

Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries Hazırlayan Asst. Prof. Dr. Tansu Filik Computer Programming Previously on Bil 200 Low-Level I/O getchar, putchar,

More information

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch Lecture 3 CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions Review Conditions: if( ) / else switch Loops: for( ) do...while( ) while( )... 1 Examples Display the first 10

More information

C Functions. 5.2 Program Modules in C

C Functions. 5.2 Program Modules in C 1 5 C Functions 5.2 Program Modules in C 2 Functions Modules in C Programs combine user-defined functions with library functions - C standard library has a wide variety of functions Function calls Invoking

More information

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Lecture 9 Functions Dr M Kasim A Jalil Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Objectives In this chapter, you will learn: To understand how to construct programs modularly

More information

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

6-1 (Function). (Function) !*+!#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x (Function) -1.1 Math Library Function!"#! $%&!'(#) preprocessor directive #include !*+!"#!, Function Description Example sqrt(x) square root of x sqrt(900.0) is 30.0 sqrt(9.0) is 3.0 exp(x) log(x)

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4 BIL 104E Introduction to Scientific and Engineering Computing Lecture 4 Introduction Divide and Conquer Construct a program from smaller pieces or components These smaller pieces are called modules Functions

More information

Functions. Systems Programming Concepts

Functions. Systems Programming Concepts Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value

More information

CSE123. Program Design and Modular Programming Functions 1-1

CSE123. Program Design and Modular Programming Functions 1-1 CSE123 Program Design and Modular Programming Functions 1-1 5.1 Introduction A function in C is a small sub-program performs a particular task, supports the concept of modular programming design techniques.

More information

today cs3157-fall2002-sklar-lect05 1

today cs3157-fall2002-sklar-lect05 1 today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical

More information

INTRODUCTION TO C++ FUNCTIONS. Dept. of Electronic Engineering, NCHU. Original slides are from

INTRODUCTION TO C++ FUNCTIONS. Dept. of Electronic Engineering, NCHU. Original slides are from INTRODUCTION TO C++ FUNCTIONS Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 Functions: Program modules in C Function Definitions Function

More information

ECET 264 C Programming Language with Applications

ECET 264 C Programming Language with Applications ECET 264 C Programming Language with Applications Lecture 10 C Standard Library Functions Paul I. Lin Professor of Electrical & Computer Engineering Technology http://www.etcs.ipfw.edu/~lin Lecture 10

More information

Chapter 4 Functions By C.K. Liang

Chapter 4 Functions By C.K. Liang 1 Chapter 4 Functions By C.K. Liang What you should learn? 2 To construct programs modularly from small pieces called functions Math functions in C standard library Create new functions Pass information

More information

Chapter 5 C Functions

Chapter 5 C Functions Chapter 5 C Functions Objectives of this chapter: To construct programs from small pieces called functions. Common math functions in math.h the C Standard Library. sin( ), cos( ), tan( ), atan( ), sqrt(

More information

Programming Fundamentals for Engineers Functions. Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. Modular programming.

Programming Fundamentals for Engineers Functions. Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. Modular programming. Programming Fundamentals for Engineers - 0702113 7. Functions Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 Modular programming Your program main() function Calls AnotherFunction1() Returns the results

More information

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Previously on Bil 200 Low-Level I/O getchar, putchar, getc, putc Control Structures if-else, switch-case, loops (while, dowhile, for loops) for loop (generic) A disturbingly

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3). cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion

More information

C Functions. CS 2060 Week 4. Prof. Jonathan Ventura

C Functions. CS 2060 Week 4. Prof. Jonathan Ventura CS 2060 Week 4 1 Modularizing Programs Modularizing programs in C Writing custom functions Header files 2 Function Call Stack The function call stack Stack frames 3 Pass-by-value Pass-by-value and pass-by-reference

More information

Functions. Autumn Semester 2009 Programming and Data Structure 1. Courtsey: University of Pittsburgh-CSD-Khalifa

Functions. Autumn Semester 2009 Programming and Data Structure 1. Courtsey: University of Pittsburgh-CSD-Khalifa Functions Autumn Semester 2009 Programming and Data Structure 1 Courtsey: University of Pittsburgh-CSD-Khalifa Introduction Function A self-contained program segment that carries out some specific, well-defined

More information

C Programs: Simple Statements and Expressions

C Programs: Simple Statements and Expressions .. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. C Programs: Simple Statements and Expressions C Program Structure A C program that consists of only one function has the following

More information

Functions. Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.

Functions. Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan. Functions Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2009 Fall Outline 5.1 Introduction 5.3 Math Library Functions 5.4 Functions 5.5

More information

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design What is a Function? C Programming Lecture 8-1 : Function (Basic) A small program(subroutine) that performs a particular task Input : parameter / argument Perform what? : function body Output t : return

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch

More information

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science

Functions in C C Programming and Software Tools. N.C. State Department of Computer Science Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

Computer Programming 3 th Week Variables, constant, and expressions

Computer Programming 3 th Week Variables, constant, and expressions 3 th Week Variables, constant, and expressions Hazırlayan Asst. Prof. Dr. Tansu Filik Previously on Bil 200 Unitary operations (applied to single variable, +.-,++,--) Type casting Operation/Operator precedence

More information

Functions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Functions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR 1 Functions Functions are everywhere in C Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Introduction Function A self-contained program segment that carries

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

Fundamentals of Programming & Procedural Programming

Fundamentals of Programming & Procedural Programming Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Eight: Math Functions, Linked Lists, and Binary Trees Name: First Name: Tutor:

More information

Introduction to C Language

Introduction to C Language Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,

More information

Computer Programming: 8th Week Pointers

Computer Programming: 8th Week Pointers Computer Programming: 8th Week Pointers Hazırlayan Asst. Prof. Dr. Tansu Filik Computer Programming Previously on Bil-200 Recursive functions, two way communications with functions (reference) Meanings

More information

Functions. Prof. Indranil Sen Gupta. Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur. Introduction

Functions. Prof. Indranil Sen Gupta. Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur. Introduction Functions Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur Programming and Data Structure 1 Function Introduction A self-contained program segment that

More information

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:

More information

Multiple Choice Questions ( 1 mark)

Multiple Choice Questions ( 1 mark) Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s

More information

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Computer Programming Previously on Bil 200 Introduction to pointers String (character array) Static and automatic variables static and automatic variables, and scope Rem: Static

More information

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved.

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved. Functions In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive. You can either use the built-in library functions or you can create

More information

Function. specific, well-defined task. whenever it is called or invoked. A function to add two numbers A function to find the largest of n numbers

Function. specific, well-defined task. whenever it is called or invoked. A function to add two numbers A function to find the largest of n numbers Functions 1 Function n A program segment that carries out some specific, well-defined task n Example A function to add two numbers A function to find the largest of n numbers n A function will carry out

More information

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering. C Tutorial: Part 1 Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering September 2013 Why C? Small (32 keywords) Stable Existing code base Fast Low-level

More information

OBJECTIVE QUESTIONS: Choose the correct alternative:

OBJECTIVE QUESTIONS: Choose the correct alternative: OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call

More information

LAB 7 FUNCTION PART 2

LAB 7 FUNCTION PART 2 LAB 7 FUNCTION PART 2 School of Computer and Communication Engineering Universiti Malaysia Perlis 1 OBJECTIVES 1. To differentiate the file scope and block scope. 2. To write recursive function. 3. To

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 1, 2015 1 M Environment console M.1 Purpose This environment supports programming

More information

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Previously on Bil 200 Operators Logical and arithmetic operators Control Structures if-else mechanism Low-level I/O They are fast! Might be useful for console applications.

More information

C Functions Pearson Education, Inc. All rights reserved.

C Functions Pearson Education, Inc. All rights reserved. 1 5 C Functions 2 Form ever follows function. Louis Henri Sullivan E pluribus unum. (One composed of many.) Virgil O! call back yesterday, bid time return. William Shakespeare Call me Ishmael. Herman Melville

More information

from Appendix B: Some C Essentials

from Appendix B: Some C Essentials from Appendix B: Some C Essentials tw rev. 22.9.16 If you use or reference these slides or the associated textbook, please cite the original authors work as follows: Toulson, R. & Wilmshurst, T. (2016).

More information

Introduction to Computers II Lecture 4. Dr Ali Ziya Alkar Dr Mehmet Demirer

Introduction to Computers II Lecture 4. Dr Ali Ziya Alkar Dr Mehmet Demirer Introduction to Computers II Lecture 4 Dr Ali Ziya Alkar Dr Mehmet Demirer 1 Contents: Utilizing the existing information Top-down design Start with the broadest statement of the problem Works down to

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

Fundamentals of Programming & Procedural Programming

Fundamentals of Programming & Procedural Programming Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Four: Functions: Built-in, Parameters and Arguments, Fruitful and Void Functions

More information

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &

More information

C Programming Language

C Programming Language C Programming Language Arrays & Pointers I Dr. Manar Mohaisen Office: F208 Email: manar.subhi@kut.ac.kr Department of EECE Review of Precedent Class Explain How to Create Simple Functions Department of

More information

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Functions Read/Study: Reek Chapters 7 Gojko Babić 01-22-2018 Predefined Functions C comes with libraries of predefined functions E.g.:

More information

C++ PROGRAMMING SKILLS Part 3 User-Defined Functions

C++ PROGRAMMING SKILLS Part 3 User-Defined Functions C++ PROGRAMMING SKILLS Part 3 User-Defined Functions Introduction Function Definition Void function Global Vs Local variables Random Number Generator Recursion Function Overloading Sample Code 1 Functions

More information

Pointers and scanf() Steven R. Bagley

Pointers and scanf() Steven R. Bagley Pointers and scanf() Steven R. Bagley Recap Programs are a series of statements Defined in functions Can call functions to alter program flow if statement can determine whether code gets run Loops can

More information

ALGORITHM 2-1 Solution for Exercise 4

ALGORITHM 2-1 Solution for Exercise 4 Chapter 2 Recursion Exercises 1. a. 3 * 4 = 12 b. (2 * (2 * fun1(0) + 7) + 7) = (2 * (2 * (3 * 0) + 7) + 7) = 21 c. (2 * (2 * fun1(2) + 7) + 7) = (2 * (2 * (3 * 2) + 7) + 7) = 45 2. a. 3 b. (fun2(2, 6)

More information

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called.

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Chapter-12 FUNCTIONS Introduction A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Types of functions There are two types

More information

UNIT III (PART-II) & UNIT IV(PART-I)

UNIT III (PART-II) & UNIT IV(PART-I) UNIT III (PART-II) & UNIT IV(PART-I) Function: it is defined as self contained block of code to perform a task. Functions can be categorized to system-defined functions and user-defined functions. System

More information

Introduction to Functions in C. Dr. Ahmed Telba King Saud University College of Engineering Electrical Engineering Department

Introduction to Functions in C. Dr. Ahmed Telba King Saud University College of Engineering Electrical Engineering Department Introduction to Functions in C Dr. Ahmed Telba King Saud University College of Engineering Electrical Engineering Department Function definition For example Pythagoras(x,y,z) double x,y,z; { double d;

More information

Programming in C. Part 1: Introduction

Programming in C. Part 1: Introduction Programming in C Part 1: Introduction Resources: 1. Stanford CS Education Library URL: http://cslibrary.stanford.edu/101/ 2. Programming in ANSI C, E Balaguruswamy, Tata McGraw-Hill PROGRAMMING IN C A

More information

Functions in C C Programming and Software Tools

Functions in C C Programming and Software Tools Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

C introduction: part 1

C introduction: part 1 What is C? C is a compiled language that gives the programmer maximum control and efficiency 1. 1 https://computer.howstuffworks.com/c1.htm 2 / 26 3 / 26 Outline Basic file structure Main function Compilation

More information

Chapter 3 - Functions

Chapter 3 - Functions Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number

More information

Government Polytechnic Muzaffarpur.

Government Polytechnic Muzaffarpur. Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking

More information

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

Dynamic memory allocation

Dynamic memory allocation Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes

More information

Lecture 04 FUNCTIONS AND ARRAYS

Lecture 04 FUNCTIONS AND ARRAYS Lecture 04 FUNCTIONS AND ARRAYS 1 Motivations Divide hug tasks to blocks: divide programs up into sets of cooperating functions. Define new functions with function calls and parameter passing. Use functions

More information

BSM540 Basics of C Language

BSM540 Basics of C Language BSM540 Basics of C Language Chapter 9: Functions I Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture Introduce the switch and goto statements Introduce the arrays in C

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 9 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel s slides Sahrif University of Technology Outlines

More information

Assoc. Prof. Dr. Tansu FİLİK

Assoc. Prof. Dr. Tansu FİLİK Assoc. Prof. Dr. Tansu FİLİK Bil 200 Week -2 Previously on Bil 200 Programming Languages (Machine Code, Assembly code, high-level languages) Compiler (translator) Software development (components of algorithm)

More information

UNIT-I Input/ Output functions and other library functions

UNIT-I Input/ Output functions and other library functions Input and Output functions UNIT-I Input/ Output functions and other library functions All the input/output operations are carried out through function calls. There exists several functions that become

More information

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015 Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 1 Wednesday, February 11, 2015 Marking Exemplar Duration of examination: 75

More information

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only

More information

Programming and Data Structure

Programming and Data Structure Programming and Data Structure Sujoy Ghose Sudeshna Sarkar Jayanta Mukhopadhyay Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Spring Semester 2012 Programming and Data

More information

Visual Studio. Visual Studio is an extremely complex interactive development environment capable of handling many languages and tools.

Visual Studio. Visual Studio is an extremely complex interactive development environment capable of handling many languages and tools. Tips and Tricks Topics Visual Studio Handling Output to the Screen Handling Input from the Keyboard Simple Text Menus When to use a For Loop When to use a While Loop Reviewing a Function Visual Studio

More information

BSM540 Basics of C Language

BSM540 Basics of C Language BSM540 Basics of C Language Chapter 4: Character strings & formatted I/O Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture To explain the input/output functions printf()

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 9 Pointer Department of Computer Engineering 1/46 Outline Defining and using Pointers

More information

C Program Structures

C Program Structures Review-1 Structure of C program Variable types and Naming Input and output Arithmetic operation 85-132 Introduction to C-Programming 9-1 C Program Structures #include void main (void) { } declaration

More information

Procedural Programming & Fundamentals of Programming

Procedural Programming & Fundamentals of Programming & Fundamentals of Programming Exercise 4 (SS 2018) 12.06.2018 What will I learn in the 5. exercise Files Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Files A file can be seen as

More information

Functions. Chapter 5

Functions. Chapter 5 Functions Chapter 5 Function Definition type function_name ( parameter list ) declarations statements For example int factorial(int n) int i, product = 1; for (i = 2; I

More information

MODULE 3: Arrays, Functions and Strings

MODULE 3: Arrays, Functions and Strings MODULE 3: Arrays, Functions and Strings Contents covered in this module I. Using an Array II. Functions in C III. Argument Passing IV. Functions and Program Structure, locations of functions V. Function

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur An Example: Random

More information

Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces

Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces Basic memory model Using functions Writing functions Basics Prototypes Parameters Return types Functions and memory Names and namespaces When a program runs it requires main memory (RAM) space for Program

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ... Why Pointers Pointers They provide the means by which functions can modify arguments in the calling function. They support dynamic memory allocation. They provide support for dynamic data structures, such

More information

File IO and command line input CSE 2451

File IO and command line input CSE 2451 File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to

More information

Structured Programming. Functions and Structured Programming. Functions. Variables

Structured Programming. Functions and Structured Programming. Functions. Variables Structured Programming Functions and Structured Programming Structured programming is a problem-solving strategy and a programming methodology. The construction of a program should embody topdown design

More information

C Review. SWE2004: Principles in Programming Spring 2014 Euiseong Seo

C Review. SWE2004: Principles in Programming Spring 2014 Euiseong Seo C Review 1 C Program Structure #include int main ( ) { variable declarations; } statements; scanf ( %d, &var); printf (..\n ); return 0; Compilation of a program: gcc o hello hello.c -o specifies

More information

Subject: Fundamental of Computer Programming 2068

Subject: Fundamental of Computer Programming 2068 Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find

More information

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow Variables Integer Representation Variables are used to store a value. The value a variable holds may change over its lifetime. At any point in time a variable stores one value (except quantum computers!)

More information

Fundamentals of Computer Programming Using C

Fundamentals of Computer Programming Using C CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US01CBCA01 (Fundamentals of Computer Programming Using C) *UNIT 3 (Structured Programming, Library Functions

More information

Standard Library Functions Outline

Standard Library Functions Outline Standard Library Functions Outline 1. Standard Library Functions Outline 2. Functions in Mathematics #1 3. Functions in Mathematics #2 4. Functions in Mathematics #3 5. Function Argument 6. Absolute Value

More information

C: How to Program. Week /Apr/23

C: How to Program. Week /Apr/23 C: How to Program Week 9 2007/Apr/23 1 Review of Chapters 1~5 Chapter 1: Basic Concepts on Computer and Programming Chapter 2: printf and scanf (Relational Operators) keywords Chapter 3: if (if else )

More information

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? Overview For this lab, you will use: one or more of the conditional statements explained below scanf()

More information

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

Chapter 1 Getting Started Structured Programming 1

Chapter 1 Getting Started Structured Programming 1 Chapter 1 Getting Started 204112 Structured Programming 1 Outline Introduction to Programming Algorithm Programming Style The printf( ) Function Common Programming Errors Introduction to Modularity Top-Down

More information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

Function a block of statements grouped together, to perform some specific task

Function a block of statements grouped together, to perform some specific task Function a block of statements grouped together, to perform some specific task Each program written in C / C++ includes at least one function with pre-defined name: main( ). In our previous programs, we

More information

SWEN-250 Personal SE. Introduction to C

SWEN-250 Personal SE. Introduction to C SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the

More information

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long LESSON 5 ARITHMETIC DATA PROCESSING The arithmetic data types are the fundamental data types of the C language. They are called "arithmetic" because operations such as addition and multiplication can be

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

Functions. CS10001: Programming & Data Structures. Sudeshna Sarkar Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Functions. CS10001: Programming & Data Structures. Sudeshna Sarkar Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Functions CS10001: Programming & Data Structures Sudeshna Sarkar Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 1 Recursion A process by which a function calls itself

More information