Functions and methods A method is a function that is a member of a class A method is a function that is a member of a class FCL(Framework Class Library)

Slides:



Advertisements
Similar presentations
Methods Java 5.1 A quick overview of methods
Advertisements

Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Building Java Programs
Return values.
A Library of Functions This presentation will review the behavior of the most common functions including their graphs and their domains and ranges. See.
Warm-up: Tuesday, March 11  In programming, what is the difference between an object and a class?
DEDiscover Differential Equation Modeling Solution CANGLIN WU June
Introduction to.NET Microsoft announced in June 2000 A new software –development model that allows applications created in disparate programming languages.
Topic 2A – Library Functions and Casting. CISC 105 – Topic 2A Functions A function is a piece of code which performs a specific task. When a function.
Functions and methods A method is a function that is a member of a class FCL(Framework Class Library) provides a rich collection of classes and methods.
 2000 Prentice Hall, Inc. All rights reserved. Functions in C Outline 1Introduction 2Program Modules in C 3Math Library Functions 4Functions 5Function.
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
10/25: Methods & templates Return to concepts: methods Math class methods 1 st Program of the day About DrawLine.java modifications Method definitions.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) MATH Functions in C Language.
CSC1015F – Chapter 3, Computing with Numbers Michelle Kuttel
CSE1222: Lecture 4The Ohio State University1. Mathematical Functions (1)  The math library file cmath Yes, this is a file with definitions for common.
CSE202: Lecture 4The Ohio State University1 Mathematical Functions.
Functions in C Outline 1Introduction 2Program Modules in C 3Math Library Functions 4Functions 5Function Definitions 6Function Prototypes 7Header Files.
Chapter 3 Expressions and Interactivity Department of Computer Science Missouri State Univeristy.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
* * 0 Chapter 6 Java Methods. * * 0 Method Syntax [access specifier][qualifier] return type method name(argument list) Access specifier public – method.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 4 part 3 GEORGE KOUTSOGIANNAKIS.
1 Functions ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
STANDARD FUNCTIONS Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
1 Math Expressions and Operators. 2 Some C++ Operators Precedence OperatorDescription Higher ( )Function call +Positive - Negative *Multiplication / Division.
Math With Java The Math Class. First, A Quick Review of Math Operators in Java Primitive Data type in Java that represent numbers: Primitive Data type.
4-Methods Dr. John P. Abraham Professor UTPA. Common ways of packaging code Properties Methods Classes Namespaces (related classes are grouped into a.
CMSC 1041 Functions II Functions that return a value.
Warm-Up: Monday, March 24 List as many commands in Java as you can remember (at least 10)
Visual Basic I Programming
Introduction As programmers, we don’t want to have to implement functions for every possible task we encounter. The Standard C library contains functions.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CSCI 125 & 161 / ENGR 144 Lecture 8 Martin van Bommel.
1 Ordinal types An ordinal data type is an ordered set in which every element, except the first element, has an immediate predecessor, and every element,
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Chapter 3: User-Defined Functions I
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
29 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
C# Programming: Basic Concept Part 2 Computer and Programming (204111)
USING & CREATING FUNCTIONS. MODULAR PROGRAMMING  Why Modular Programming?  Improves Readability & Understandability  Improve Maintainability  Allows.
1 nd Semester Module2 C# Basic Concept Thanawin Rakthanmanon Computer Engineering Department Kasetsart University, Bangkok.
Recursion It is a process of calling the same function itself again and again until some condition is satisfied. Syntax: func1() { ……….. func1(); }
Parent Functions. Learning Goal I will be able to recognize parent functions, graphs, and their characteristics.
Today Variable declaration Mathematical Operators Input and Output Lab
Chapter 6: User-Defined Functions I
Functions in C ++ Subject: Programming Languages ​​for III year Topic: functions, member class.
FUNCTION Functions is a sub-program that contains one or more statements and it performs some task when called.
Mathematical Functions
Built-in MATLAB Functions Chapter 3
BIL 104E Introduction to Scientific and Engineering Computing
TMF1414 Introduction to Programming
Functions, Part 2 of 2 Topics Functions That Return a Value
Computer Simulation Lab
FUNCTIONS EXAMPLES.
Fundamental of Java Programming Basics of Java Programming
Introduction to Programming
Math Library and IO formatting
Functions October 23, 2017.
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods
Chapter 6: User-Defined Functions I
class 5 retrieving a previous statement in Thonny or IDLE // %
Output Formatting Bina Ramamurthy 4/16/2019 BR.
月夜憶舍弟 戍鼓斷人行,邊秋一雁聲。 露從今夜白,月是故鄉明。 有弟皆分散,無家問死生。 寄書長不達,況乃未休兵。 杜甫
月夜憶舍弟 戍鼓斷人行,邊秋一雁聲。 露從今夜白,月是故鄉明。 有弟皆分散,無家問死生。 寄書長不達,況乃未休兵。 杜甫
Input, Variables, and Mathematical Expressions
Output Formatting Bina Ramamurthy 9/25/2019 BR.
Presentation transcript:

Functions and methods A method is a function that is a member of a class A method is a function that is a member of a class FCL(Framework Class Library) provides a rich collection of classes and methods FCL(Framework Class Library) provides a rich collection of classes and methods Console Console String String Programmer defined functions Programmer defined functions

Math class methods Abs(x) absolute value of x Abs(x) absolute value of x Ceiling(x) round x to smallest integer not less than x Ceiling(x) round x to smallest integer not less than x Cos(x) cosine of x Cos(x) cosine of x Exp(x) exponential e^x Exp(x) exponential e^x Floor(x) rounds x to the largest integer not greater than x Floor(x) rounds x to the largest integer not greater than x Log(x) natural logarithm of x ( base e) Log(x) natural logarithm of x ( base e) Max(x,y) larger value of x and y Max(x,y) larger value of x and y Min(x,y) smaller value of x and y Min(x,y) smaller value of x and y Pow( x, y) x raised to power y Pow( x, y) x raised to power y Sin(x) sine of x Sin(x) sine of x Sqrt( x) square root of x Sqrt( x) square root of x Tan( x) tangent of x Tan( x) tangent of x

Example b = 5;a = 2;c = -2; b = 5;a = 2;c = -2; Console::WriteLine( Math::Sqrt(b*b – 4*a*c)); Console::WriteLine( Math::Sqrt(b*b – 4*a*c));

Random number generation Class Random located in namespace System Class Random located in namespace System Create a object of class Random Create a object of class Random Random *ran = new Random(); Random *ran = new Random(); A random integer number between 0 and constant Int32::MaxValue ( 2,147,483,647) A random integer number between 0 and constant Int32::MaxValue ( 2,147,483,647) int num = ran->Next(); int num = ran->Next(); Random number between 0 and 5 Random number between 0 and 5 int num2 = ran->Next(6); int num2 = ran->Next(6);

String String::Concat(x.ToString(), S”\t”, (x+y).ToString()); String::Concat(x.ToString(), S”\t”, (x+y).ToString());

namespace The Standard C++ Library includes many names for the various classes, functions, variables, and other code it contains The Standard C++ Library includes many names for the various classes, functions, variables, and other code it contains In addition, you can define your own custom names for the programmatic elements in your applications In addition, you can define your own custom names for the programmatic elements in your applications The using directive informs your program that you intend to use a namespace The using directive informs your program that you intend to use a namespace using namespace name; using namespace name;

Namespaces in MC++ Systemessential class and types Systemessential class and types System::Dataclasses form ADO.NET, used for database access and manipulation System::Dataclasses form ADO.NET, used for database access and manipulation System::Drawingclasses used for drawing and graphic System::Drawingclasses used for drawing and graphic System::IOclasses for input and output of data System::IOclasses for input and output of data System::Threadingclasses for multithreading, used to run multiple parts of a program simultanously System::Threadingclasses for multithreading, used to run multiple parts of a program simultanously System::Windows::Formsclasses used to create GUI System::Windows::Formsclasses used to create GUI System::Xmlclasses used to process XML data System::Xmlclasses used to process XML data