The document discusses looping in programming languages. It covers the for, while, do-while loops and the break and continue statements. Examples are provided to calculate triangular numbers using different loops and to find the greatest common divisor of two numbers using a while loop. The document contains 14 sections covering various looping concepts in programming.
The document discusses looping statements in Java, including while, do-while, and for loops. It provides the syntax for each loop and explains their logic and flow. While and for loops check a condition before each iteration of the loop body. Do-while loops check the condition after executing the body at least once. Nested loops run the inner loop fully for each iteration of the outer loop. Infinite loops occur if the condition is never made false, causing the program to run indefinitely.
This document discusses different types of conditional statements in object-oriented programming languages, including if statements, switch statements, and the conditional operator. It provides examples of using if statements to check conditions, if/else statements, logical operators like AND and OR, compound conditional tests, and nested if statements.
The document discusses separating object-oriented programming code into interface and implementation files. It shows how to define an interface for a Fraction class in a header file and provide the implementation in a separate file. It also covers compiling the code from the command line or using a makefile. The document then demonstrates synthesizing accessor methods to allow accessing properties using dot notation rather than message passing syntax.
OOP: Chapter 2: Programming in Objective-C Atit Patumvan
This document discusses programming in Objective-C. It presents several example programs that demonstrate basic Objective-C syntax like importing frameworks, using NSAutoreleasePool, NSLog functions, and performing calculations. It also explains how to compile and run Objective-C programs on different platforms like OSX, Windows, and Linux. Common filename extensions for different programming languages are also listed.
OOP Chapter 3: Classes, Objects and MethodsAtit Patumvan
This document discusses object-oriented programming concepts like classes, objects, and methods. It provides an example class for representing fractions that defines instance variables to store the numerator and denominator. It demonstrates creating fraction objects, setting properties on objects by calling methods, and accessing instance variables. The class defines an interface with method signatures and an implementation that includes method definitions to print fractions, set property values, and return property values.
The document discusses software metrics and regression testing. It defines software metrics as quantitative methods for assessing software quality. Metrics can be measured through techniques applied to the software development lifecycle and products. This allows for providing meaningful management information and improving processes. Types of metrics discussed include size, control flow, and data metrics. Regression testing involves re-running existing test suites on modified programs to identify new issues. The document also provides examples of measuring complexity for a sample program using metrics like lines of code, cyclomatic complexity, and Halstead metrics to analyze effort.
This document provides an overview of topics to be covered in R Programming including variables, data types, data import/export, logical statements, loops, functions, data plotting and visualization, and basic statistical functions and packages. It then goes on to introduce R, explaining that it is a programming language for statistical analysis and graphical display. It discusses why R is useful for data analysis and exploration due to its large collection of tools, ability to handle big data, and open source community support. The document also covers installing R and RStudio, defining variables, common data types like vectors, matrices, arrays, lists and data frames, and basic operations and control structures like if/else statements and loops.
The document discusses looping statements in Java, including while, do-while, and for loops. It provides the syntax for each loop and explains their logic and flow. While and for loops check a condition before each iteration of the loop body. Do-while loops check the condition after executing the body at least once. Nested loops run the inner loop fully for each iteration of the outer loop. Infinite loops occur if the condition is never made false, causing the program to run indefinitely.
This document discusses different types of conditional statements in object-oriented programming languages, including if statements, switch statements, and the conditional operator. It provides examples of using if statements to check conditions, if/else statements, logical operators like AND and OR, compound conditional tests, and nested if statements.
The document discusses separating object-oriented programming code into interface and implementation files. It shows how to define an interface for a Fraction class in a header file and provide the implementation in a separate file. It also covers compiling the code from the command line or using a makefile. The document then demonstrates synthesizing accessor methods to allow accessing properties using dot notation rather than message passing syntax.
OOP: Chapter 2: Programming in Objective-C Atit Patumvan
This document discusses programming in Objective-C. It presents several example programs that demonstrate basic Objective-C syntax like importing frameworks, using NSAutoreleasePool, NSLog functions, and performing calculations. It also explains how to compile and run Objective-C programs on different platforms like OSX, Windows, and Linux. Common filename extensions for different programming languages are also listed.
OOP Chapter 3: Classes, Objects and MethodsAtit Patumvan
This document discusses object-oriented programming concepts like classes, objects, and methods. It provides an example class for representing fractions that defines instance variables to store the numerator and denominator. It demonstrates creating fraction objects, setting properties on objects by calling methods, and accessing instance variables. The class defines an interface with method signatures and an implementation that includes method definitions to print fractions, set property values, and return property values.
The document discusses software metrics and regression testing. It defines software metrics as quantitative methods for assessing software quality. Metrics can be measured through techniques applied to the software development lifecycle and products. This allows for providing meaningful management information and improving processes. Types of metrics discussed include size, control flow, and data metrics. Regression testing involves re-running existing test suites on modified programs to identify new issues. The document also provides examples of measuring complexity for a sample program using metrics like lines of code, cyclomatic complexity, and Halstead metrics to analyze effort.
This document provides an overview of topics to be covered in R Programming including variables, data types, data import/export, logical statements, loops, functions, data plotting and visualization, and basic statistical functions and packages. It then goes on to introduce R, explaining that it is a programming language for statistical analysis and graphical display. It discusses why R is useful for data analysis and exploration due to its large collection of tools, ability to handle big data, and open source community support. The document also covers installing R and RStudio, defining variables, common data types like vectors, matrices, arrays, lists and data frames, and basic operations and control structures like if/else statements and loops.
This document discusses algorithm analysis and complexity. It explains that algorithm analysis aims to predict performance by analyzing time and space complexity as functions of input size. Time complexity indicates how fast an algorithm runs, while space complexity refers to memory usage. Common complexities include constant, logarithmic, linear, linearithmic, polynomial, and exponential orders of growth. The analysis framework focuses on analyzing asymptotic order of growth for running time and memory usage as input size increases.
This document is a lab manual for the course "Analysis and Design of Algorithms" at Amity University Haryana. It contains 11 experiments on algorithms including binary search, merge sort, quicksort, knapsack problem, and graph algorithms like Kruskal, Prim's, BFS and DFS. The introduction provides an overview of algorithm design and analysis. The experiments provide code snippets in C/C++ to implement the given algorithms.
Computer Programming Chapter 6 : Array and ArrayListAtit Patumvan
This document summarizes key aspects of arrays and arraylists in Java. It discusses that an array is a fundamental data structure for storing a collection of data elements of the same type. Each element in an array can be referenced using an index. The document also provides examples of declaring and initializing arrays, accessing array elements, and common operations like finding the sum and average of array elements.
The document contains summaries of 12 programs implementing various operating system concepts like memory management algorithms, CPU scheduling algorithms, and page replacement algorithms. It includes programs for first fit, best fit, worst fit, priority scheduling, producer consumer problem, FCFS, SJF, SRTF, round robin, and page replacement algorithms like FIFO, LRU, and optimal page replacement. For each program, it lists the code, inputs/outputs and provides a brief 1-2 line description.
OOP Chapter 4: Data Type and ExpressionsAtit Patumvan
This document discusses data types and expressions in Objective-C. It covers basic data types like int, float, char, and boolean. It also discusses arithmetic expressions using operators like addition, subtraction, multiplication, division, and modulus. Examples are provided to demonstrate how to use different data types and perform calculations in Objective-C.
This document discusses algorithm analysis and determining the time complexity of algorithms. It begins by defining an algorithm and noting that the efficiency of algorithms should be analyzed independently of specific implementations or hardware. The document then discusses analyzing the time complexity of various algorithms by counting the number of operations and expressing efficiency using growth functions. Common growth functions like constant, linear, quadratic, and exponential are introduced. The concept of asymptotic notation (Big O) for describing an algorithm's time complexity is also covered. Examples are provided to demonstrate how to determine the time complexity of iterative and recursive algorithms.
The document provides information about algorithms including:
- Algorithms are step-by-step procedures to solve problems and are represented in programs, pseudocode, or flowcharts.
- Common algorithm applications include sorting, data retrieval, routing, and games.
- Pseudocode is an informal way to describe algorithms using a combination of English and programming languages.
- Algorithm analysis evaluates correctness, efficiency, complexity, and other factors.
The document discusses various topics related to arrays in C programming language. It begins by defining an array as a collection of data storage locations of the same type and name. It then discusses declaring, initializing and accessing elements of single and multi-dimensional arrays using indices. The document also demonstrates inserting elements into an array, deleting elements from an array, and printing the elements of an array.
SIGDOC 2011 - Necessary and Neglected? An Empirical Study of Internal Documen...Christoph Johann Stettina
Presentation slides for the "Necessary and Neglected? An Empirical Study of Internal Documentation in Agile Software Development Teams" paper presented at SIGDOC 2011
The document discusses using Internet of Things (IoT) technology for smart agriculture. It provides an overview of IoT and how devices can communicate over a network without human interaction. It then discusses how microcontrollers like Arduino can be used to interface with sensors and actuators to monitor and control the physical environment for applications like smart farming. The document provides examples of using sensors to collect environmental data and controlling devices like motors and lights through a microcontroller.
An Overview of eZee Burrp! (Philus Limited)Atit Patumvan
1) Philus Limited produces restaurant management software called eZee BurrP! which provides a point of sale system, digital menus, and customer feedback system to help restaurants improve operations and customer experience.
2) The software allows restaurants to manage reservations, inventory, sales reporting, payroll and integrate with third parties. It also provides digital menus for customers to view and order from tablets.
3) The customer feedback system allows restaurants to collect surveys and reviews from customers through various methods to build customer loyalty and engagement. It also manages multi-location restaurant chains from one system.
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตAtit Patumvan
This document contains an example practice set on sets. It includes questions to determine if elements are members of sets, to find the power set, subset, union, intersection and complement of various sets. Sets are defined using notation such as intervals of integers and set builder notation. Students are asked to write out the elements of sets resulting from operations on the given sets.
Media literacy provides a framework for accessing, analyzing, evaluating, and creating various messages from print to video to the internet. It builds an understanding of media's role in society and teaches important inquiry and self-expression skills for citizens of a democracy. Social media literacy involves having the proficiency to communicate appropriately and responsibly on social networks, and to critically evaluate online conversations. It includes skills like impression management, monitoring one's online reputation, thinking critically about content, having responsible conversations, managing one's social media presence, and managing information and technology.
The document discusses performance measures for total quality management. It outlines several objectives of establishing performance measures such as establishing baselines, determining process improvements needed, and comparing goals to actual performance. Several criteria for effective performance measures are listed, including being simple, relevant to customers, and enabling improvement. Examples of performance measures are provided for strategies involving quality, cost, flexibility, reliability, and innovation. Methods for presenting performance measures like time series graphs and control charts are also mentioned.
This document discusses algorithm analysis and complexity. It explains that algorithm analysis aims to predict performance by analyzing time and space complexity as functions of input size. Time complexity indicates how fast an algorithm runs, while space complexity refers to memory usage. Common complexities include constant, logarithmic, linear, linearithmic, polynomial, and exponential orders of growth. The analysis framework focuses on analyzing asymptotic order of growth for running time and memory usage as input size increases.
This document is a lab manual for the course "Analysis and Design of Algorithms" at Amity University Haryana. It contains 11 experiments on algorithms including binary search, merge sort, quicksort, knapsack problem, and graph algorithms like Kruskal, Prim's, BFS and DFS. The introduction provides an overview of algorithm design and analysis. The experiments provide code snippets in C/C++ to implement the given algorithms.
Computer Programming Chapter 6 : Array and ArrayListAtit Patumvan
This document summarizes key aspects of arrays and arraylists in Java. It discusses that an array is a fundamental data structure for storing a collection of data elements of the same type. Each element in an array can be referenced using an index. The document also provides examples of declaring and initializing arrays, accessing array elements, and common operations like finding the sum and average of array elements.
The document contains summaries of 12 programs implementing various operating system concepts like memory management algorithms, CPU scheduling algorithms, and page replacement algorithms. It includes programs for first fit, best fit, worst fit, priority scheduling, producer consumer problem, FCFS, SJF, SRTF, round robin, and page replacement algorithms like FIFO, LRU, and optimal page replacement. For each program, it lists the code, inputs/outputs and provides a brief 1-2 line description.
OOP Chapter 4: Data Type and ExpressionsAtit Patumvan
This document discusses data types and expressions in Objective-C. It covers basic data types like int, float, char, and boolean. It also discusses arithmetic expressions using operators like addition, subtraction, multiplication, division, and modulus. Examples are provided to demonstrate how to use different data types and perform calculations in Objective-C.
This document discusses algorithm analysis and determining the time complexity of algorithms. It begins by defining an algorithm and noting that the efficiency of algorithms should be analyzed independently of specific implementations or hardware. The document then discusses analyzing the time complexity of various algorithms by counting the number of operations and expressing efficiency using growth functions. Common growth functions like constant, linear, quadratic, and exponential are introduced. The concept of asymptotic notation (Big O) for describing an algorithm's time complexity is also covered. Examples are provided to demonstrate how to determine the time complexity of iterative and recursive algorithms.
The document provides information about algorithms including:
- Algorithms are step-by-step procedures to solve problems and are represented in programs, pseudocode, or flowcharts.
- Common algorithm applications include sorting, data retrieval, routing, and games.
- Pseudocode is an informal way to describe algorithms using a combination of English and programming languages.
- Algorithm analysis evaluates correctness, efficiency, complexity, and other factors.
The document discusses various topics related to arrays in C programming language. It begins by defining an array as a collection of data storage locations of the same type and name. It then discusses declaring, initializing and accessing elements of single and multi-dimensional arrays using indices. The document also demonstrates inserting elements into an array, deleting elements from an array, and printing the elements of an array.
SIGDOC 2011 - Necessary and Neglected? An Empirical Study of Internal Documen...Christoph Johann Stettina
Presentation slides for the "Necessary and Neglected? An Empirical Study of Internal Documentation in Agile Software Development Teams" paper presented at SIGDOC 2011
The document discusses using Internet of Things (IoT) technology for smart agriculture. It provides an overview of IoT and how devices can communicate over a network without human interaction. It then discusses how microcontrollers like Arduino can be used to interface with sensors and actuators to monitor and control the physical environment for applications like smart farming. The document provides examples of using sensors to collect environmental data and controlling devices like motors and lights through a microcontroller.
An Overview of eZee Burrp! (Philus Limited)Atit Patumvan
1) Philus Limited produces restaurant management software called eZee BurrP! which provides a point of sale system, digital menus, and customer feedback system to help restaurants improve operations and customer experience.
2) The software allows restaurants to manage reservations, inventory, sales reporting, payroll and integrate with third parties. It also provides digital menus for customers to view and order from tablets.
3) The customer feedback system allows restaurants to collect surveys and reviews from customers through various methods to build customer loyalty and engagement. It also manages multi-location restaurant chains from one system.
แบบฝึกหัดวิชา Theory of Computation ชุดที่ 1 เซ็ตAtit Patumvan
This document contains an example practice set on sets. It includes questions to determine if elements are members of sets, to find the power set, subset, union, intersection and complement of various sets. Sets are defined using notation such as intervals of integers and set builder notation. Students are asked to write out the elements of sets resulting from operations on the given sets.
Media literacy provides a framework for accessing, analyzing, evaluating, and creating various messages from print to video to the internet. It builds an understanding of media's role in society and teaches important inquiry and self-expression skills for citizens of a democracy. Social media literacy involves having the proficiency to communicate appropriately and responsibly on social networks, and to critically evaluate online conversations. It includes skills like impression management, monitoring one's online reputation, thinking critically about content, having responsible conversations, managing one's social media presence, and managing information and technology.
The document discusses performance measures for total quality management. It outlines several objectives of establishing performance measures such as establishing baselines, determining process improvements needed, and comparing goals to actual performance. Several criteria for effective performance measures are listed, including being simple, relevant to customers, and enabling improvement. Examples of performance measures are provided for strategies involving quality, cost, flexibility, reliability, and innovation. Methods for presenting performance measures like time series graphs and control charts are also mentioned.
This document discusses principles of customer-supplier relationships in total quality management, including partnering, sourcing, supplier selection, supplier rating, and relationship development. The key points are that customers and suppliers should have long-term commitments based on trust and shared visions, methods for evaluating quality and supplier performance are important, and close collaboration through inspection, training, and team approaches helps develop strong relationships.
The document discusses various methods for continuous process improvement, including Juran's Trilogy, the DPSA cycle, Kaizen, and Six Sigma. It describes Juran's Trilogy as a systematic approach involving quality planning, control, and improvement. The DPSA cycle is a method for testing changes through planning, doing, studying, and acting on the results. Kaizen focuses on small, incremental changes to minimize waste and promote continuous improvement. Six Sigma provides a scientific, data-driven approach to process improvement and achieving significant financial results.
This document provides an introduction to Java EE (J2EE) including:
- An overview of the Model View Controller (MVC) design pattern and its core elements.
- A definition of Java EE as an open, standard platform for developing and deploying n-tier, web-enabled enterprise applications.
- An explanation of what comprises Java EE including specifications, implementations, compatibility testing, and more.
This document discusses various aspects of employee involvement in total quality management, including motivation, surveys, empowerment, teams, suggestion systems, and performance appraisal. It describes how understanding employee motivations and establishing clear goals can increase motivation. It also outlines different types of teams, characteristics of successful teams, and the stages of team development. Suggestion systems and performance appraisal are discussed as well.
The document discusses key aspects of customer satisfaction and quality management. It defines internal and external customers and explains how customer perception is influenced by factors like performance, features, service, price and reputation. The document also outlines methods for obtaining customer feedback, using customer complaints to improve, and translating customer needs into requirements. Customer retention is identified as an important goal.
The document discusses key aspects of leadership for Total Quality Management. It defines characteristics of quality leaders as emphasizing customers, prevention, collaboration and coaching. It also outlines the 7 Habits of Highly Effective People and Deming's philosophy. The roles of TQM leaders are described as ensuring decisions align with quality statements and participating in quality celebrations. The quality council duties include developing quality policies and plans.
This document provides an introduction to computer programming and programming languages. It discusses what programming is, the history and evolution of programming languages from machine languages to higher-level languages. It describes assembly languages, third-generation languages like Java and C++, fourth-generation languages, and debates the existence of fifth-generation languages. The document also discusses Java in more detail, including its history, editions, features, environment, and common misconceptions. It provides an example of a simple "Hello World" Java program.
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...EduSkills OECD
Andreas Schleicher, Director of Education and Skills at the OECD presents at the launch of PISA 2022 Volume III - Creative Minds, Creative Schools on 18 June 2024.
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.pptHenry Hollis
The History of NZ 1870-1900.
Making of a Nation.
From the NZ Wars to Liberals,
Richard Seddon, George Grey,
Social Laboratory, New Zealand,
Confiscations, Kotahitanga, Kingitanga, Parliament, Suffrage, Repudiation, Economic Change, Agriculture, Gold Mining, Timber, Flax, Sheep, Dairying,
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumMJDuyan
(𝐓𝐋𝐄 𝟏𝟎𝟎) (𝐋𝐞𝐬𝐬𝐨𝐧 𝟏)-𝐏𝐫𝐞𝐥𝐢𝐦𝐬
𝐃𝐢𝐬𝐜𝐮𝐬𝐬 𝐭𝐡𝐞 𝐄𝐏𝐏 𝐂𝐮𝐫𝐫𝐢𝐜𝐮𝐥𝐮𝐦 𝐢𝐧 𝐭𝐡𝐞 𝐏𝐡𝐢𝐥𝐢𝐩𝐩𝐢𝐧𝐞𝐬:
- Understand the goals and objectives of the Edukasyong Pantahanan at Pangkabuhayan (EPP) curriculum, recognizing its importance in fostering practical life skills and values among students. Students will also be able to identify the key components and subjects covered, such as agriculture, home economics, industrial arts, and information and communication technology.
𝐄𝐱𝐩𝐥𝐚𝐢𝐧 𝐭𝐡𝐞 𝐍𝐚𝐭𝐮𝐫𝐞 𝐚𝐧𝐝 𝐒𝐜𝐨𝐩𝐞 𝐨𝐟 𝐚𝐧 𝐄𝐧𝐭𝐫𝐞𝐩𝐫𝐞𝐧𝐞𝐮𝐫:
-Define entrepreneurship, distinguishing it from general business activities by emphasizing its focus on innovation, risk-taking, and value creation. Students will describe the characteristics and traits of successful entrepreneurs, including their roles and responsibilities, and discuss the broader economic and social impacts of entrepreneurial activities on both local and global scales.
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
This presentation was provided by Racquel Jemison, Ph.D., Christina MacLaughlin, Ph.D., and Paulomi Majumder. Ph.D., all of the American Chemical Society, for the second session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session Two: 'Expanding Pathways to Publishing Careers,' was held June 13, 2024.
1. Object-Oriented Programming Language
Chapter 5 : Program Looping
Atit Patumvan
Faculty of Management and Information Sciences
Naresuan University
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
2. 2
Contents
• The for statement
• The while statement
• The do statement
• The break and continue Statements
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
3. 3
Triangular Number
n=4
sum = 1 + 2 + ... + n
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
4. 4
Triangular Number Example
Program 5.1
01: #import <Foundation/Foundation.h>
02:
03:// Program to calculate the eighth triangular number
04:
05: int main(int argc, const char * argv[])
06:{
07:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
08:! int triangularNumber;
09:
10:! triangularNumber = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8;
11:
12:! NSLog(@"The eighth triangular number is %i", triangularNumber);
13:
14:! [pool drain];
15:! return 0;
16:}
The eighth triangular number is 36
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
5. 5
The for Statement
Program 5.2
01: #import <Foundation/Foundation.h>
02:
03:
04: int main(int argc, const char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! int n, triangularNumber;
08:
09:! triangularNumber = 0;
10:
11:! for(n = 1; n <= 200; n = n + 1)
12:! ! triangularNumber +=n;
13:
14:! NSLog(@"The 200th triangular number is %i", triangularNumber);
15:
16:! [pool drain];
17:! return 0;
18: }
The 200th triangular number is 20100
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
6. 6
The for Statement
for( init_expression; loop_condition; loop_expression)
program_statement;
11:!for(n = 1; n <= 200; n = n + 1)
12:!! triangularNumber +=n;
1. The initial expression is evaluate first.
2. The looping condition is evaluated.
3. The program statement is executed.
4.The looping expression is evaluated.
5. Return to step 2.
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
7. 7
Table ot Triangular Number
Program 5.3
01: #import <Foundation/Foundation.h>
02:
03:
04: int main(int argc, const char * argv[])
05: {
06:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
07:! int n, triangularNumber;
08:
09:! NSLog(@"TABLE OF TRIANGULAR NUMBERS");
10:! NSLog(@" n Sum from 1 to n");
11:! NSLog(@"-- ----------------"); for( init_expression; loop_condition; loop_expression)
12:
13:! triangularNumber = 0;
program_statement;
14:
TABLE OF TRIANGULAR NUMBERS
15:! for(n = 1; n <= 10; ++n){ n Sum from 1 to n
16:! ! triangularNumber +=n; -- ----------------
17:! ! NSLog(@" %i t%i", n, triangularNumber); 1 1
18:! } 2 3
3 6
19: 4 10
20:! NSLog(@"The 200th triangular number is %i", triangularNumber); 5 15
21: 6 21
7 28
22:! [pool drain]; 8 36
23:! return 0; 9 45
24: } 10 55
The 200th triangular number is 55
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
8. 8
Keyboard Input
Program 5.4
01: #import <Foundation/Foundation.h>
02:
03: int main(int argc, const char * argv[])
04: {
05:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
06:! int n, number, triangularNumber;
07:
08:! NSLog(@"What triangular number do you want?");
09:! scanf("%i", &number);
10:
11:! triangularNumber = 0;
12:
13:! for(n = 1; n <= number; ++n){
14:! ! triangularNumber +=n;
15:! }
16:
17:! NSLog(@"Triangular number %i is %in", number, triangularNumber);
18:
19:! [pool drain];
20:! return 0;
21: } What triangular number do you want?
22: 100
Triangular number 100 is 5050
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
9. 9
Nested for Loops
Program 5.5
05: #import <Foundation/Foundation.h>
05:
05: int main(int argc, const char * argv[])
05: {
05:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
05:! int n, number, triangularNumber, counter;
05:
05:! for(counter = 1; counter <= 5; ++counter){
05:! ! NSLog(@"What triangular number do you want?");
05:! ! scanf("%i", &number);
05:
05:! ! triangularNumber = 0;
05:
05:! ! for(n = 1; n <= number; ++n){
05:! ! ! triangularNumber +=n;
05:! ! }
05:
05:! ! NSLog(@"Triangular number %i is %i", number, triangularNumber);
05: ! }
05:! [pool drain];
05:! return 0;
05: }
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
10. 10
The while Statement
while( expression )
program_statement
init_expression;
while( loop_condition )
{
program_statement;
loop_expression;
}
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
11. 11
The while Statement
Program 5.6
01: #import <Foundation/Foundation.h>
02:
03: int main(int argc, const char * argv[])
04: {
05:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
06:! int count = 1;
07:
08:! while( count <= 5){ init_expression;
09:! ! NSLog(@"%i", count); while( loop_condition )
10:! ! ++count;
11:! } {
12: program_statement;
13:! [pool drain]; loop_expression;
14:! return 0; }
15: }
16:!
1
2
3
4
5
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
12. 12
Find the greatest common divisor
Program 5.7
01: #import <Foundation/Foundation.h>
02:
03: int main(int argc, const char * argv[])
04: {
05:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
06:! unsigned int u, v, temp;
30 18
07:
08:! NSLog(@"Please type in two nonnegative integers.");
09:! scanf("%u%u", &u, &v);
10: 30 /18 = 1R12
11:! while( v != 0){
12:! ! temp = u % v; 18 /12 = 1R6
12 / 6 = 2R0
13:! ! u = v;
14:! ! v = temp;
15:! }
16:
17:! NSLog(@"Their greatest common advisor is %u", u);
18:
19:! [pool drain];
20:! return 0; Please type in two nonnegative integers.
21: } 30 18
22: Their greatest common advisor is 6
!
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
13. 13
Program to reverse the digits of number
Program 5.8
01: #import <Foundation/Foundation.h>
01:
01: int main(int argc, const char * argv[])
01:{
01:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
01:! int number, right_digit;
01:
01:! NSLog(@"Enter your number.");
1234 % 10 = 4
01:! scanf("%i", &number);
01:
01:! while( number != 0){
01:! ! right_digit = number % 10;
01:! ! NSLog(@"%i", right_digit);
1234 / 10 = 123
01:! ! number /= 10;
01:! }
01:
01:! [pool drain]; 123 % 10 = 3
01:! return 0;
01:} Enter your number.
123 /10 = 12
:
01: 1234
! 4
3
2
1
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
14. 14
The do Statement
do
program_statement
while( expression )
init_expression;
do {
program_statement;
loop_expression;
} while( loop_condition )
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
15. 15
Program to reverse the digits of number
Program 5.9
01: #import <Foundation/Foundation.h>
02:
03: int main(int argc, const char * argv[])
04: {
05:! NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
06:! int number, right_digit;
07:
08:! NSLog(@"Enter your number.");
09:! scanf("%i", &number);
10:
11:! do{ init_expression;
12:! ! right_digit = number % 10; do{
13:! ! NSLog(@"%i", right_digit);
14:! ! number /= 10; program_statement;
15:! }while( number != 0); loop_expression;
16: } while( loop_condition );
17:! [pool drain];
18:! return 0;
19: }
01:!
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12
16. 16
The break and continue Statements
• Labeled break statement
• Exit from nested control structures
• Proceeds to end of specified labeled block
• Labeled continue statement
• Skips remaining statements in nested-loop body
• Proceeds to beginning of specified labeled block
Atit Patumvan, Faculty of Management and Information Sciences, Naresuan University Object-Oriented Programming Language
วันจันทร์ท่ี 27 กุมภาพันธ์ 12