tailieunhanh - Lecture Computing for management - Chapter 29

Lecture 29 - Functions and pointers. After studying this chapter you will be able to understand: control structures; examine relational and logical operators; explore how to form and evaluate logical (boolean) expressions; discover how to use the selection control structures if, , and switch in a program; learn to use the assert function to terminate a program;. | Functions and Pointers Lecture 29 CSE1301 Sem 2, 2003 Lecture 14: Functions Part 2 Summary of Previous Lecture Algorithms Functions Using functions in top-down design Functions in C Language User defined Functions Parameters Return values CSE1301 Sem 2 - 2003 Lecture 12: Algorithm Design Topics Functions Prototypes Variable Scope Pointers Introduction to pointers Pointers and function parameters Summary CSE1301 Sem 2, 2003 Lecture 14: Functions Part 2 Prototyping of Functions Must declare functions before use (like variables) Declaration is called a “prototype” Specifies the name, parameters and return type of the function, but not the code #include int isNegative (int); int main (void) { int number; printf ("Enter an integer: "); scanf ("%d",&number); if (isNegative(number)) { printf("Negative\n"); } else { printf("Positive\n"); } return 0; } Example: int isNegative ( int n ) { int result; if ( n int isNegative (int); int main (void) { int number; printf ("Enter an integer: "); scanf ("%d",&number); if (isNegative(number)) { printf("Negative\n"); } else { printf("Positive\n"); } return 0; } int isNegative ( int n ) { int result; if ( n int isNegative (int); int main (void) { int number; printf ("Enter an integer: "); scanf ("%d",&number); if (isNegative(number)) { printf("Negative\n"); } else { printf("Positive\n"); } return 0; } int isNegative ( int n ) { int result; if ( n int isNegative (int); int main (void) { int number; printf ("Enter an integer: "); scanf ("%d",&number); if (isNegative(number)) { printf("Negative\n"); } else { printf("Positive\n"); } return 0; } int isNegative ( int n ) { int result; if ( n Summary of Previous Lecture Algorithms Functions Using functions in top-down design Functions in C Language User defined Functions Parameters Return values CSE1301 Sem 2 - 2003 Lecture 12: Algorithm Design Topics Functions Prototypes Variable Scope Pointers Introduction to pointers Pointers and function parameters Summary CSE1301 Sem 2, 2003 Lecture 14: Functions Part 2 Prototyping of Functions Must declare functions before use (like variables) Declaration is called a “prototype” Specifies the name, parameters and return type of the function, but not the code #include int isNegative (int); int main (void) { int number; printf ("Enter an integer: "); scanf ("%d",&number); if (isNegative(number)) { printf("Negative\n"); } else { printf("Positive\n"); } return 0; } Example: int isNegative ( int n ) { int result; if ( n<0 ) { result=1; } else { result = 0; } return .

TÀI LIỆU LIÊN QUAN
TỪ KHÓA LIÊN QUAN