This document discusses different programming paradigms including procedural, object-oriented, and declarative paradigms. It provides examples of code using these paradigms. Specifically, it shows an assembly language program that adds two numbers, a C++ program that calculates the area of a rectangle, and Prolog queries to retrieve information from a database about people's genders and family relationships. It also discusses how parameters are used to pass values to functions in Visual Basic.
The document discusses various topics related to C language including:
- Benefits and features of C like low-level operations, structured programming, and modular programming
- Data types in C like fundamental types (char, int, float), derived types, and defining variables
- Structure of C functions including single-level and multiple-level functions
- Input-output functions in C like character-based (getc, putc), string-based (gets, puts)
Cs6660 compiler design may june 2016 Answer Keyappasami
The document describes the various phases of a compiler:
1. Lexical analysis breaks the source code into tokens.
2. Syntax analysis generates a parse tree from the tokens.
3. Semantic analysis checks for semantic correctness using the parse tree and symbol table.
4. Intermediate code generation produces machine-independent code.
5. Code optimization improves the intermediate code.
6. Code generation translates the optimized code into target machine code.
This document discusses object-oriented programming in C++. It covers several topics related to OOP in C++ including classes, constructors, destructors, inheritance, polymorphism, and templates. The document consists of lecture slides that define key concepts and provide examples to illustrate how various OOP features work in C++.
This document provides an overview of the C programming language. It discusses the origins and development of C from the B programming language. Some key features and benefits of C discussed include its low-level capabilities as a second-generation language, structured programming approach, use of functions and libraries, and support for pointers, memory allocation, recursion, and bit manipulation. The document also covers C's fundamental and derived data types, defining variables and strings, and the structure of C functions including single-level functions.
This document discusses operators, loops, and formatted input/output functions in C. It covers various categories of operators, how they work, and precedence rules. Loops like for, while and do-while are explained along with break and continue. Formatted I/O functions printf() and scanf() are described, including their syntax and use of format specifiers for input and output of different data types.
This document provides an overview of C++ programming concepts including:
1. C++ programs consist of functions, with every program containing a main() function. Functions contain declarations, statements, comments, and can call libraries.
2. Variables must be declared with a type and can be used to store values. C++ supports integer, floating point, character, and other variable types.
3. C++ allows selection and decision making using if/else statements, switch statements, logical operators, and loops like while and for. Operators allow comparisons and boolean evaluations.
This document provides an introduction to the C++ programming language. It discusses what C++ is, its origins as an extension of the C language, and some key concepts in C++ programs. These include variables, data types, functions, input/output statements, and a simple example program. The document then demonstrates arithmetic, relational, and logical operations and examines pseudocode as a way to design algorithms before coding. Decision statements and flowcharts are introduced as tools for programming logic and conditional execution.
R is an open source statistical programming language developed from S at the University of Auckland in 1993. It is dynamically typed and treats vectors as first-class objects. Functions in R are also objects that can be assigned to variables. R has various options for binding scalars and vectors together into arrays and data frames for aggregate analysis. It also includes many built-in functions for numerical, statistical, and character manipulation of data.
The document discusses various topics related to C language including:
- Benefits and features of C like low-level operations, structured programming, and modular programming
- Data types in C like fundamental types (char, int, float), derived types, and defining variables
- Structure of C functions including single-level and multiple-level functions
- Input-output functions in C like character-based (getc, putc), string-based (gets, puts)
Cs6660 compiler design may june 2016 Answer Keyappasami
The document describes the various phases of a compiler:
1. Lexical analysis breaks the source code into tokens.
2. Syntax analysis generates a parse tree from the tokens.
3. Semantic analysis checks for semantic correctness using the parse tree and symbol table.
4. Intermediate code generation produces machine-independent code.
5. Code optimization improves the intermediate code.
6. Code generation translates the optimized code into target machine code.
This document discusses object-oriented programming in C++. It covers several topics related to OOP in C++ including classes, constructors, destructors, inheritance, polymorphism, and templates. The document consists of lecture slides that define key concepts and provide examples to illustrate how various OOP features work in C++.
This document provides an overview of the C programming language. It discusses the origins and development of C from the B programming language. Some key features and benefits of C discussed include its low-level capabilities as a second-generation language, structured programming approach, use of functions and libraries, and support for pointers, memory allocation, recursion, and bit manipulation. The document also covers C's fundamental and derived data types, defining variables and strings, and the structure of C functions including single-level functions.
This document discusses operators, loops, and formatted input/output functions in C. It covers various categories of operators, how they work, and precedence rules. Loops like for, while and do-while are explained along with break and continue. Formatted I/O functions printf() and scanf() are described, including their syntax and use of format specifiers for input and output of different data types.
This document provides an overview of C++ programming concepts including:
1. C++ programs consist of functions, with every program containing a main() function. Functions contain declarations, statements, comments, and can call libraries.
2. Variables must be declared with a type and can be used to store values. C++ supports integer, floating point, character, and other variable types.
3. C++ allows selection and decision making using if/else statements, switch statements, logical operators, and loops like while and for. Operators allow comparisons and boolean evaluations.
This document provides an introduction to the C++ programming language. It discusses what C++ is, its origins as an extension of the C language, and some key concepts in C++ programs. These include variables, data types, functions, input/output statements, and a simple example program. The document then demonstrates arithmetic, relational, and logical operations and examines pseudocode as a way to design algorithms before coding. Decision statements and flowcharts are introduced as tools for programming logic and conditional execution.
R is an open source statistical programming language developed from S at the University of Auckland in 1993. It is dynamically typed and treats vectors as first-class objects. Functions in R are also objects that can be assigned to variables. R has various options for binding scalars and vectors together into arrays and data frames for aggregate analysis. It also includes many built-in functions for numerical, statistical, and character manipulation of data.
C is a procedural programming language. It was developed in the early 1970s and is still widely used. The document provides an overview of key aspects of C including data types, variables, constants, operators, control statements like if/else, and functions. It also discusses C programming concepts like low-level vs high-level languages, header files, comments, escape sequences, and more. The document serves as a useful introduction and reference for someone learning the basics of the C programming language.
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
This document discusses key concepts of object-oriented programming in C++ including abstraction, encapsulation, polymorphism, inheritance, and runtime polymorphism. It explains that abstraction allows hiding details behind well-defined interfaces, encapsulation provides guarantees that abstractions are used correctly, and polymorphism simplifies code by providing a common interface for different implementations. Inheritance enables composing new abstractions from existing ones, and runtime polymorphism provides runtime binding. Coexistence with other languages and systems is also important.
The document discusses intermediate code generation in compilers. It aims to generate a machine-independent intermediate form (IR) that is suitable for optimization and portability. The IR facilitates retargeting compilers to new machines and enables machine-independent code optimization. Common IR representations include abstract syntax trees, directed acyclic graphs, control flow graphs, postfix notation, and three-address code. Three-address code is a simple representation where instructions have at most three operands. It allows efficient code manipulation and optimization.
The document outlines the course content for a C++ introductory course, including introductions to OOP concepts like classes and objects, pointers, functions, inheritance, and polymorphism. It also covers basic C++ programming concepts like I/O, data types, operators, and data structures. The course aims to provide students with fundamental C++ programming skills through explanations and examples of key C++ features.
The document provides an overview of the C programming language. It states that C was developed in 1972 by Dennis Ritchie at Bell Labs and was used to develop the UNIX operating system. The document then covers various features of C like it being a mid-level programming language, having structured programming, pointers, loops, functions, arrays, and more. It provides examples to explain concepts like input/output functions, data types, operators, control structures, and pointers.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, input/output, and how to compile and execute a C program.
This document provides an introduction to the C programming language. It begins by defining automation and explaining how computers and programming relate to automation. It then discusses different types of programming languages including machine language, assembly language, and high-level languages like C. The document explains the basic components of a C program and different data types. It also covers various operators, decision-making statements, and loop control structures in C programming.
A parser is a program component that breaks input data into smaller elements according to the rules of a formal grammar. It builds a parse tree representing the syntactic structure of the input based on these grammar rules. There are two main types of parsers: top-down parsers start at the root of the parse tree and work downward, while bottom-up parsers start at the leaves and work upward. Parser generators use attributes like First and Follow to build parsing tables for predictive parsers like LL(1) parsers, which parse input from left to right based on a single lookahead token.
C programming is a general-purpose language developed in the 1970s to write operating systems like UNIX. It is one of the most widely used languages, particularly for systems programming. Some key facts: C was created to develop UNIX and is still widely used for operating systems, compilers, databases and other modern programs. It has various data types like integers, floats, characters, arrays and structures. Variables are defined with a data type and can be initialized. C code is written in files with a .c extension and preprocessed before compilation.
The document contains 40 multiple choice questions related to computer science class 12. It covers topics like variables, data types, operators, loops, functions, arrays and more. The questions test concepts like escape sequences, format specifiers, assignment operators, comments, input/output functions, and the difference between various loops in C programming language. It is a practice test to help students prepare for their computer science exam.
This document provides an introduction to programming in the C language. It discusses various data types in C including predefined and user-defined types. It also covers control structures like conditional statements, loops, functions and block statements. Examples are provided to illustrate definitions of structures like records and unions, as well as pointers, arrays and file I/O operations.
This document discusses generics in C++. It introduces template functions and template classes as ways to reuse code by leaving key types unspecified. Template functions allow functions to operate on different data types, while template classes allow classes to work with different types. The document also discusses bounded genericity, which allows placing restrictions on template arguments, and issues with inheritance and generics.
The document provides an overview of key concepts in C++, including:
1) C++ adds object-oriented programming capabilities to C while maintaining C's power and flexibility. It was created in 1979 to provide object-oriented programming features to C.
2) Object-oriented programming encourages breaking problems into constituent parts called objects that contain related instructions and data. The three main traits of OOP are encapsulation, polymorphism, and inheritance.
3) C++ supports both traditional and modern styles, with newer headers placed in the std namespace. Keywords like class, public, and virtual allow defining classes and controlling access to members. Functions can be overloaded if their signatures differ.
This is Work-In-Progress. Developing a series of lectures on C++0x. This will augment my presentations on C++ and Design Pattern. First trial run was done at Interra, Noida in 2009
The document describes intermediate code generation during compilation.
1) An intermediate language is used to translate source programs into a form that is CPU independent yet close to machine language. This facilitates code optimization and retargeting of compilers.
2) Common intermediate languages include syntax trees, postfix notation, and three-address code using quadruples. Three-address code breaks down expressions into single assignment statements to simplify optimization.
3) Semantic rules for syntax-directed translation are described to generate three-address code for expressions, assignments, procedures, and other language constructs. Attributes track temporary variables and generated code.
C programming & data structure [character strings & string functions]MomenMostafa
The document provides information about C programming language and data structures. It includes references to books and websites on the topics. The document outlines topics that will be covered, including arrays and pointers, strings and string functions, structures, algorithms, stacks, queues and trees. It then gives details on a lesson about string functions, including examples of gets(), puts(), fgets() and other standard library string functions.
Peter Paul van de Beek presented on using a service bus to connect a supply chain. The goal was to create a complete view of all retail transactions to enable centralized reporting and management. A service bus was designed using patterns like schema centralization, asynchronous queuing, and data transformation. This allowed different participants in the supply chain to integrate while maintaining independence. Performance was monitored during a pilot rollout and improvements were made to address issues found, like reducing response times and matching information flows.
The YUI 3.4.0 release includes major updates to the App Framework, YUI and Loader modules, Calendar, and Graphics API. It also contains new widget plugins and bug fixes. Key changes include the launch of the App Framework beta, improvements to the Loader to reduce file size and support module rollup, and updates to the Calendar and Graphics modules to utilize new APIs and features.
C is a procedural programming language. It was developed in the early 1970s and is still widely used. The document provides an overview of key aspects of C including data types, variables, constants, operators, control statements like if/else, and functions. It also discusses C programming concepts like low-level vs high-level languages, header files, comments, escape sequences, and more. The document serves as a useful introduction and reference for someone learning the basics of the C programming language.
C programming_MSBTE_Diploma_Pranoti DokePranoti Doke
"1.1 Structure of ‘C’program, Assembler, Linker, Compiler, Interpreter.
1.2 ‘C’character set-keywords, identifiers, types of constants (Integer, single character, string, and real) variables, scope of variables, concept of ASCII.
1.3 Data types: integer- unsigned, signed, long, float- float, double, character char, string, octal, hexadecimal
1.4 Algorithm and flow chart.
1.5 Formatted input and output statements. Input and output function.
1.6 Operators and expressions:
a. Operators in ‘C’- arithmetic, logical, assignment, relational, increment and decrement, conditional, bit wise, special operators
b. Expressions
c. Precedence and associatively."
"2.1 Decision making if statement (if, if-else, nested if-else), switch –case statement.
2.2 Repetition in ‘C’ (loop control
statement) while, do-while and for loop, break and continue statement, nested loops
"
"3.1 Introduction to Array and its types
3.2 Declaration, initialization of array,
accessing elements of an array, adding,
deleting, sorting & searching.
3.3 Introduction to string Initializing,
declaring and display of string
3.4 String handling functions from standard library (strlen (), strcpy (), strcat (), strcmp(), strlwr(),strupr()):
"
"4.1 Concept and need of functions
4.2 Library functions: Math functions,
String handling functions, other
miscellaneous functions.
4.3 Writing User defined functions, scope of variables.
4.4 Parameter passing: call by value, call by reference.
4.5 Recursive functions
"
"5.1 Concept of pointer and pointer variables, initialization of pointer, call-by reference.
5.2 Pointer arithmetic.
5.3 Handling arrays using pointers
5.4 Handling functions using pointers
"
"6.1 Introduction and Features and Syntax of structure
6.2 Declaration and Initialization of
Structures
6.3 Initializing, assessing structure members using pointers
6.4 Type def, Enumerated Data Type,
using structures in C Program
6.5 Operations on structure."
This document discusses key concepts of object-oriented programming in C++ including abstraction, encapsulation, polymorphism, inheritance, and runtime polymorphism. It explains that abstraction allows hiding details behind well-defined interfaces, encapsulation provides guarantees that abstractions are used correctly, and polymorphism simplifies code by providing a common interface for different implementations. Inheritance enables composing new abstractions from existing ones, and runtime polymorphism provides runtime binding. Coexistence with other languages and systems is also important.
The document discusses intermediate code generation in compilers. It aims to generate a machine-independent intermediate form (IR) that is suitable for optimization and portability. The IR facilitates retargeting compilers to new machines and enables machine-independent code optimization. Common IR representations include abstract syntax trees, directed acyclic graphs, control flow graphs, postfix notation, and three-address code. Three-address code is a simple representation where instructions have at most three operands. It allows efficient code manipulation and optimization.
The document outlines the course content for a C++ introductory course, including introductions to OOP concepts like classes and objects, pointers, functions, inheritance, and polymorphism. It also covers basic C++ programming concepts like I/O, data types, operators, and data structures. The course aims to provide students with fundamental C++ programming skills through explanations and examples of key C++ features.
The document provides an overview of the C programming language. It states that C was developed in 1972 by Dennis Ritchie at Bell Labs and was used to develop the UNIX operating system. The document then covers various features of C like it being a mid-level programming language, having structured programming, pointers, loops, functions, arrays, and more. It provides examples to explain concepts like input/output functions, data types, operators, control structures, and pointers.
The document provides an introduction to the C programming language, including its history, features, character sets, tokens, data types, operators, and the basic structure of a C program. It discusses key concepts such as variables, constants, comments, functions, input/output, and how to compile and execute a C program.
This document provides an introduction to the C programming language. It begins by defining automation and explaining how computers and programming relate to automation. It then discusses different types of programming languages including machine language, assembly language, and high-level languages like C. The document explains the basic components of a C program and different data types. It also covers various operators, decision-making statements, and loop control structures in C programming.
A parser is a program component that breaks input data into smaller elements according to the rules of a formal grammar. It builds a parse tree representing the syntactic structure of the input based on these grammar rules. There are two main types of parsers: top-down parsers start at the root of the parse tree and work downward, while bottom-up parsers start at the leaves and work upward. Parser generators use attributes like First and Follow to build parsing tables for predictive parsers like LL(1) parsers, which parse input from left to right based on a single lookahead token.
C programming is a general-purpose language developed in the 1970s to write operating systems like UNIX. It is one of the most widely used languages, particularly for systems programming. Some key facts: C was created to develop UNIX and is still widely used for operating systems, compilers, databases and other modern programs. It has various data types like integers, floats, characters, arrays and structures. Variables are defined with a data type and can be initialized. C code is written in files with a .c extension and preprocessed before compilation.
The document contains 40 multiple choice questions related to computer science class 12. It covers topics like variables, data types, operators, loops, functions, arrays and more. The questions test concepts like escape sequences, format specifiers, assignment operators, comments, input/output functions, and the difference between various loops in C programming language. It is a practice test to help students prepare for their computer science exam.
This document provides an introduction to programming in the C language. It discusses various data types in C including predefined and user-defined types. It also covers control structures like conditional statements, loops, functions and block statements. Examples are provided to illustrate definitions of structures like records and unions, as well as pointers, arrays and file I/O operations.
This document discusses generics in C++. It introduces template functions and template classes as ways to reuse code by leaving key types unspecified. Template functions allow functions to operate on different data types, while template classes allow classes to work with different types. The document also discusses bounded genericity, which allows placing restrictions on template arguments, and issues with inheritance and generics.
The document provides an overview of key concepts in C++, including:
1) C++ adds object-oriented programming capabilities to C while maintaining C's power and flexibility. It was created in 1979 to provide object-oriented programming features to C.
2) Object-oriented programming encourages breaking problems into constituent parts called objects that contain related instructions and data. The three main traits of OOP are encapsulation, polymorphism, and inheritance.
3) C++ supports both traditional and modern styles, with newer headers placed in the std namespace. Keywords like class, public, and virtual allow defining classes and controlling access to members. Functions can be overloaded if their signatures differ.
This is Work-In-Progress. Developing a series of lectures on C++0x. This will augment my presentations on C++ and Design Pattern. First trial run was done at Interra, Noida in 2009
The document describes intermediate code generation during compilation.
1) An intermediate language is used to translate source programs into a form that is CPU independent yet close to machine language. This facilitates code optimization and retargeting of compilers.
2) Common intermediate languages include syntax trees, postfix notation, and three-address code using quadruples. Three-address code breaks down expressions into single assignment statements to simplify optimization.
3) Semantic rules for syntax-directed translation are described to generate three-address code for expressions, assignments, procedures, and other language constructs. Attributes track temporary variables and generated code.
C programming & data structure [character strings & string functions]MomenMostafa
The document provides information about C programming language and data structures. It includes references to books and websites on the topics. The document outlines topics that will be covered, including arrays and pointers, strings and string functions, structures, algorithms, stacks, queues and trees. It then gives details on a lesson about string functions, including examples of gets(), puts(), fgets() and other standard library string functions.
Peter Paul van de Beek presented on using a service bus to connect a supply chain. The goal was to create a complete view of all retail transactions to enable centralized reporting and management. A service bus was designed using patterns like schema centralization, asynchronous queuing, and data transformation. This allowed different participants in the supply chain to integrate while maintaining independence. Performance was monitored during a pilot rollout and improvements were made to address issues found, like reducing response times and matching information flows.
The YUI 3.4.0 release includes major updates to the App Framework, YUI and Loader modules, Calendar, and Graphics API. It also contains new widget plugins and bug fixes. Key changes include the launch of the App Framework beta, improvements to the Loader to reduce file size and support module rollup, and updates to the Calendar and Graphics modules to utilize new APIs and features.
This document provides an overview of commonly used Unix commands available on systems at the University of Missouri-Columbia. It describes logging on, getting assistance, control characters and basic command formatting. Logging on involves telnetting to a system, entering your user ID and password, and reading any login announcements. Assistance is available through man pages and gopher. Control characters like Ctrl-C, Ctrl-D and Ctrl-Z are explained.
This document discusses various techniques for data processing including data cleaning, integration, transformation, reduction, and similarity/dissimilarity measures. It describes common types of dirty or incomplete data like missing values, noisy data, and inconsistent data. It also discusses techniques for handling different types of dirty data, such as filling in missing values, smoothing noisy data, and resolving inconsistencies. Major tasks in data processing include data cleaning, integration, transformation, and reduction. Specific techniques discussed include binning, clustering, regression, normalization, aggregation, and dimensionality reduction. The document also provides details on various similarity and dissimilarity measures that can be used to calculate the proximity between data objects.
This document discusses how to prepare and file insurance claims using the CMS-1500 form, either electronically or via paper. It also covers tracking outstanding claims, receiving insurance payments, and applying them to patient accounts. The process for billing secondary insurance by creating a new claim and attaching the primary EOB is also outlined.
The document discusses whether horseback riding is a sport. It notes that sports generally involve activity, skills, rules, and competition. It then checks that horseback riding involves these elements. Some equestrian sporting events are listed, including dressage, eventing, jumping, racing, and rodeo. The document states that equestrianism, meaning horse riding or horsemanship, is one of the oldest sports dating back to 4500 BC.
Este documento describe la configuración y activación de un servidor de correo electrónico en Mac OS X Server. Explica cómo configurar los servicios de red, DNS, Open Directory, Workgroup Manager y Mail para habilitar cuentas de correo y envío/recepción de mensajes.
The document discusses using cooperation and insight to improve businesses. It defines cooperation as collaboration and insight as intelligence. It describes how SharePoint can enable cooperation across dispersed groups through features like team sites, document sharing and workflows. It also explains how business intelligence tools can provide insight by integrating data from multiple sources, performing analysis and generating reports. Case studies show how a church used these tools to understand parishioner involvement and a firm analyzed project performance.
This slide corresponds with Wrench, McCroskey, and Richmond's (2008) Human Communication in Everyday Life: Explanations and Applications published by Allyn and Bacon.
This document discusses protecting clients' data and brand reputation by tackling data security issues. It identifies top worries like social media, ineffective patching, and email. It asks key questions about data management and outlines that data loss prevention alone cannot fully protect data both on and off premises from human and physical factors. It emphasizes that the largest challenge is fixing the human element through extensive user training and fostering a security-focused culture. It also stresses the need for a holistic approach combining technical controls and user awareness training to securely protect data at all stages.
Una computadora es un dispositivo electrónico que acepta información de entrada, la procesa y produce información de salida. Se compone de hardware físico como dispositivos de entrada, salida, memoria y un procesador, así como software de programas. Los dispositivos de entrada incluyen teclados, mouses y escáneres, mientras que las salidas son monitores, impresoras y modems. La memoria son dispositivos como RAM, discos duros y CDs que almacenan información e instrucciones para el procesador.
El documento habla sobre la presencia de los partidos políticos en las redes sociales y cómo intentan conseguir votos a través de plataformas como Twitter, Facebook y Tuenti. Explica que los partidos usan un "susurro" constante en las redes para llegar a los votantes, aunque no queda claro cuáles son sus estrategias exactas ni si sus esfuerzos en línea han sido efectivos.
This document discusses various security issues related to computer systems and networks. It covers authentication methods, threats like Trojan horses and viruses, intrusion detection techniques, and encryption standards. It also describes security classifications used by the Department of Defense and security features in Windows NT.
This document discusses computer viruses and application security. It begins by defining a computer virus and describing how viruses spread and their symptoms. It then covers various types of viruses like resident, direct action, overwrite, boot, macro, and polymorphic viruses. The document also discusses other malware like worms, Trojans, spyware and adware. It emphasizes the importance of application security for protecting data integrity, confidentiality, availability and accountability. It provides examples of basic security concepts and outlines strategies for securing applications like authentication, authorization, access control, logging and auditing. The document concludes by stating that developing secure applications requires an ethical hacking perspective to prevent data and system loss or misuse.
This document discusses the importance of social support for making successful changes in one's life. It identifies seven types of support: listening support, shared experience support, technical support, participatory support, motivational support, emotional support, and practical support. Each type is described briefly. The document advises the reader to think about which people in their life can provide which types of support, and to directly ask those people for help to make requested changes.
This document provides an introduction to the C programming language. It discusses key concepts like functions, variables, data types, memory, scopes, expressions, operators, control flow with if/else statements and loops. It also explains how passing arguments by value means functions cannot directly modify their parameters, but passing addresses allows modifying variables in the calling scope. Overall it serves as a helpful primer on basic C syntax and programming concepts for newcomers to the language.
The document discusses the basics of C programming language including the need for programming languages, problem solving, algorithms, flowcharts, pseudocode, data types, variables, operators, expressions, conditional statements, and arrays. It explains the basic structure of a C program, functions like main(), return statement, preprocessor directives, different types of variables and operators used in C programming.
Presentation by Jacob van Etten.
CCAFS workshop titled "Using Climate Scenarios and Analogues for Designing Adaptation Strategies in Agriculture," 19-23 September in Kathmandu, Nepal.
This document provides an overview of the C programming language, including its history, uses, basic environment, data types, variables, operators, control structures like if/else statements and loops. It begins with the origins of C in the 1970s and explains that C combines high- and low-level language features, making it useful for systems programming tasks like operating systems and compilers. Examples are provided throughout to illustrate core C concepts like getting user input, performing calculations, and repeating actions with for, while and do-while loops.
This document provides information about Python programming language and programming concepts. It discusses what a programming language is and types of programming languages like high-level and low-level languages. Python is presented as a flexible, intuitive and open source language that is good for beginners. The document outlines goals for using Python in 9th grade computer science courses, including programming fundamentals like sequencing, variables, input/output, selection, repetition and data structures. It also discusses computational thinking concepts. The rest of the document provides information on using the PyCharm IDE, creating a Python project and file, and examples of basic Python code.
The document provides an overview of the history and basics of C++ programming. It discusses:
- Bjarne Stroustrup created C++ in the early 1980s as an extension of C to support object-oriented programming.
- A typical C++ environment includes a program development environment, the C++ language itself, and the C++ Standard Library.
- A C++ program goes through several phases: edit, preprocess, compile, link, load, and execute.
- Basic C++ concepts covered include variables, data types, operators, and common errors.
C++ programming language basic to advance levelsajjad ali khan
C/C++ is a procedural programming language developed in the 1970s. C++ builds on C and adds object-oriented programming capabilities. Some key differences between C and C++ include C++ supporting classes, function overloading, and operator overloading. C++ is commonly used to create operating systems, compilers, databases, games, and other application software. The document then discusses C++ history, creators, uses, data types, variables, operators, control flow statements like if/else and loops, arrays, and multi-dimensional arrays. It provides examples of C++ code and basics of the C++ programming language.
This document provides information on C programming concepts including data types, operators, functions, and basic program structure.
It defines key concepts like variables, data types (integer, float, character), operators (arithmetic, relational, logical), functions (printf, scanf), and basic program anatomy with main(), I/O statements, and comments. Examples are given to illustrate variable declaration and usage, arithmetic operations, type casting, and basic programs to read/write and perform calculations.
The document discusses algorithms and flowcharts. It defines an algorithm as a finite set of steps to solve a problem and notes that algorithms can be expressed in various ways, including pseudocode and flowcharts. Pseudocode uses a language similar to programming but without specific syntax, making it readable by programmers familiar with different languages. A flowchart provides a graphical representation of an algorithm's logical flow. The document provides examples of algorithms expressed in pseudocode and represented through flowcharts, such as finding the average of two numbers and calculating the largest of several inputs. It also discusses common flowchart structures like sequence, selection, and iteration.
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxdonnajames55
COMP 2103X1 Assignment 2
Due Thursday, January 26 by 7:00 PM
General information about assignments (important!):
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/General-info.html
Information on passing in assignments:
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/Pass-in-info.html
Information on coding style:
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/C-coding-style-notes
[1] A filter program is a program which reads its input from “standard input” (“stdin”) and writes
its output to “standard output” (“stdout”). Filter programs are useful because they make it easy
to combine the functions they provide to solve more complex problems using the standard shell
facilities. Filter programs are also nice to write, because the programmer doesn’t have to worry
about writing code to open and close files, nor does the programmer have to worry about dealing
with related error conditions. In some respects, filter programs are truly “win-win”.
Write a filter program which uses getchar() to read in characters from stdin, continuing until
end of file (read the man page and/or textbook to see the details on getchar(), or, heaven forbid,
review the class slides). Your program must count the number of occurrences of each character in
the input. After having read all of the input, it outputs a table similar to the one below which, for
each character seen at least once, lists the total number of times that character was seen as well as
its relative frequency (expressed as a percentage). Note that the characters \n, \r, \t, \0, \a, \b,
\f, and \v (see man ascii) must be displayed with the appropriate “escape sequence”. Ordinary
printable characters must be output as themselves. Non-printable characters (see man isprint)
must be printed with their three-digit octal code (see man printf).
You can get input into a filter program (a2p1 in this case) in three ways:
(a) “pipe” data from another program into it, like
$ echo blah blah | a2p1
(b) “redirect” the contents of a file into the program, like
$ a2p1 < some-file
(c) type at the keyboard, and (eventually) type ^D (control-d) at the beginning of a line to
signify end of file.
Your output must look like the following, for this sample case:
$ echo ^Aboo | a2p1
Char Count Frequency
--------------------------
001 1 20.00%
\n 1 20.00%
b 1 20.00%
o 2 40.00%
Note: in the above examples, and from now on in this course’s assignments, text in red is text that
the human types, and a “$" at the beginning of a line like that represents the shell prompt.
1
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/General-info.html
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/Pass-in-info.html
http://cs.acadiau.ca/~jdiamond/comp2103/assignments/C-coding-style-notes
Note that I entered a ^A (control-a, not the circumflex character followed by the capital A) by
typing ^V^A. The ^V tells your shell that you want it to interpret the next character literally, rather
than to use any special meani.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, build statistical models and visualize results. Key features of R include its extensive library of statistical and graphical methods, machine learning algorithms, and ability to handle large and complex data. R is widely used in academia and industry for data science tasks like data analysis, modeling, and communicating results.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, build statistical models and visualize results. Key features of R include its extensive library of statistical and graphical methods, machine learning algorithms, and ability to handle large and complex data. R is widely used in academia and industry for data science tasks like data analysis, modeling, and communicating results.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, create visualizations and build predictive models. Key features of R include its extensive library of statistical and machine learning methods, ability to handle large datasets, and functionality for data wrangling, modeling, visualization and communication of results. The document provides instructions on downloading and installing R and RStudio, loading and installing packages, and introduces basic R programming concepts like vectors, matrices, data frames and factors.
Compiler chapter six .ppt course materialgadisaAdamu
The document discusses intermediate code generation in compilers. It explains that intermediate code serves as a bridge between the high-level source code and final machine code. It presents different types of intermediate representations like syntax trees and three-address code. Syntax trees abstract away details from parse trees while three-address code translates expressions into a linear representation using temporary variables. The document also provides examples and explanations of different data structures used to represent three-address code like quadruples and triples.
This document provides a quick introduction to the C programming language. It discusses basic C syntax like main functions, header files, comments, and variables. It also covers data types, memory, functions, scopes, expressions, control flow statements like if/else and loops. Functions can access arguments and global variables from their own scope but not variables from outer scopes unless passing their addresses.
The document provides a quick introduction to C programming, covering topics like functions, variables, memory, expressions, and recursion. It uses a recursive pow() function to demonstrate recursion and the call stack. Each function call gets its own copy of arguments and local variables, stored on the call stack.
The document provides a quick introduction to C programming. It discusses some key concepts in C including functions, variables, memory, data types, expressions and evaluation, and recursion. It provides an example of a recursive pow() function to calculate powers and discusses how function calls are handled through the stack.
C++ is a general-purpose programming language created by Bjarne Stroustrup in 1979. It has imperative, object-oriented and generic programming features. The structure of a C++ program includes preprocessor directives, a main() function, and a program body. Variables are declared with a data type and used to store and manipulate data. C++ supports various operators for arithmetic, relational, logical, and bitwise operations.
This document provides an outline and overview of key Python concepts including operators, data types, variables, functions, and program flow. It introduces Python as an interpreted programming language with a strict syntax. Operators like +, -, *, / perform actions on operands to produce new values. Data types include integers, floats, booleans and strings. Variables are used to store and reference data. Functions allow for code reuse and abstraction by defining reusable blocks of code. Program flow can be controlled using conditional statements like if/else.
This document contains a password and instructions stating that the password provided is the one typed during installation. It repeats the password and instructions twice with additional numbers that do not provide further context.
This document appears to be a lab sheet containing measurements of an unknown quantity (QU) taken multiple times. The document lists measurements of the unknown quantity taken at intervals, with the numbers increasing from 2 to 11 for each successive measurement.
This very short document contains a series of numbers and letters with no other context. It lists the characters "QU" followed by the numbers 1 through 9. No other meaning or purpose is evident from the limited information provided.
No document was provided to summarize. A summary requires source text to extract the key points and essential information from. Without a document, it is not possible to generate an accurate 3 sentence summary.
Emotional intelligence was first defined scientifically in 1990 by Mayer and Salovey, building on prior concepts. Goleman later proposed it involves five traits that determine one's EQ. Emotional intelligence involves self and social awareness and management. It is debated whether EQ can be accurately measured, though tests do exist to assess specific skills or provide an overall assessment. While EQ may help predict some life outcomes, it does not determine success on its own, and high IQ individuals like Einstein had low EQ without hindrance. EQ is significant for social and workplace interactions but is not a sole predictor of life outcomes and has limitations as a concept.
This document discusses databases and the evolution from flat files to relational databases. It covers:
1) The limitations of flat files including data duplication, separation of data across files, fixed queries, and proliferation of application programs.
2) The introduction of hierarchical and network databases to try to overcome limitations but these still led to inconsistent and redundant data.
3) An introduction to relational databases which overcome limitations by allowing each record to be of fixed length and each field to contain a single data item. This addresses issues with variable length records in previous approaches.
The document discusses the functions and purposes of translators in computing. It describes:
1) Interpreters and compilers translate programs from high-level languages to machine code. Compilers translate the entire program at once, while interpreters translate instructions one at a time as the program runs.
2) Translation from high-level languages to machine code involves multiple stages including lexical analysis, syntax analysis, code generation, and optimization.
3) Linkers and loaders are used to combine separately compiled modules into a complete executable program by resolving addresses and linking the modules together.
This document discusses common network environments, connectivity, and security issues. It describes how LANs and WANs are organized using different topologies and transmission mediums. It then explains key network components like switches, routers, bridges, and modems - how they connect different types of networks and segments. Finally, it discusses common network environments like the Internet, intranets, and extranets as well as technologies that enable them such as hypertext links, URLs, domain names, and HTML.
The operating system must manage hardware resources, provide an interface between users/software and hardware, and provide services like data security. It schedules programs to make best use of the processor when programs are performing input/output tasks. It uses interrupts to change the normal order of program execution in response to events like I/O device signals. Scheduling aims to maximize system usage, be fair to all programs, and prioritize more important programs when needed.
The document discusses computer architecture and the fetch-execute cycle. It describes the Von Neumann architecture, which uses a single processor that follows a linear sequence of fetching, decoding, and executing instructions. It then explains the fetch-execute cycle in more detail with the steps involved. Finally, it discusses parallel processor systems that can split up the fetching, decoding, and executing stages to improve efficiency.
The document discusses techniques for developing computer systems, including structured systems analysis and design method (SSADM) and data flow diagrams (DFDs). It provides details on the stages of SSADM and the symbols and steps used to develop DFDs. An example of a hotel reservation and payment system is presented as a DFD to illustrate the technique. Project management is also discussed, with an example of building a bungalow broken down into tasks, durations, and dependencies shown in a graph.
The document discusses different ways of representing numerical data in computing systems, including:
1) Binary representation, which converts decimal numbers to binary by repeatedly dividing by column headings and tracking the remainders as 1s and 0s.
2) Negative numbers can be represented using sign-and-magnitude or two's complement methods.
3) Other number systems like octal and hexadecimal are also discussed which use different column headings but the same representation principles.
4) Floating point representation separates a real number into a mantissa and exponent to store fractional numbers more efficiently in binary.
The document discusses how data and databases are valuable to organizations. It provides examples of how stock control systems and sales data can be used to automatically reorder stock. Banks also find customer data valuable for assessing loan risks. Modern communication allows sharing of data worldwide through value added network services and databases. Standards are needed for sharing data accurately between different systems. Computers now aid various forms of communication like voice mail, e-commerce, and video conferencing. The internet allows global communication and advertising. IT training must be continually updated as technology changes, which is altering many work patterns and jobs.
This document discusses real-time systems and simulation. It defines a real-time system as one that can react quickly enough to input data to affect the real world. Real-time applications include airline booking systems and nuclear reactor controls. Sensors measure physical quantities and transmit data to processors, while actuators accept signals from processors and initiate physical movements. Simulations allow computers to model real-world systems and scenarios through calculations, enabling testing without real-world risks or costs. Simulations have limitations in predicting truly random or complex human events. Parallel processing is needed for simulations involving vast data, complex relationships, and immense calculations.
This document is an exam for an Advanced Subsidiary Level computing exam. It contains 9 questions testing knowledge of topics like memory addressing, data structures, networks, and software development processes. The exam is 2 hours and contains multiple choice, short answer, and longer explanatory questions.
This document contains the mark scheme for the May/June 2002 GCE Advanced Subsidiary and Advanced Level Computing exam. It outlines the requirements and allocation of marks for each question. Examiners are instructed to award marks based on the criteria in the scheme but also have flexibility to award marks for valid alternative answers. The mark scheme should be read along with the question papers and exam report. CIE will not enter discussions about the mark scheme.
1. Chapter 3.5 Programming Paradigms
3.5 Introduction
3.5 (a) Programming Paradigms
Programming paradigms are simply methods of programming. Initially, computers
were programmed using binary. This was difficult and led to many errors that were
difficult to find. Programs written in binary are said to be written in machine code,
this is a very low-level programming paradigm.
To make programming easier, assembly languages were developed. These replaced
machine code functions with mnemonics and addresses with labels. Assembly
language programming is also a low-level paradigm although it is a second generation
paradigm. Figure 3.5.a.1 shows an assembly language program that adds together two
numbers and stores the result.
Label Function Address Comments
LDA X Load the accumulator with the value of X
ADD Y Add the value of Y to the accumulator
STA Z Store the result in Z
STOP Stop the program
X: 20 Value of X = 20
Y: 35 Value of Y = 35
Z: Location for result
Figure 3.5.a.1
Although this assembly language is an improvement over machine code, it is still
prone to errors and code is difficult to debug, correct and maintain.
The next advance was the development of procedural languages. These are third
generation languages and are also known as high-level languages. These languages
are problem oriented as they use terms appropriate to the type of problem being
solved. For example, COBOL (Common Business Oriented Language) uses the
language of business. It uses terms like file, move and copy.
FORTRAN (FORmula TRANslation) and ALGOL (ALGOrithmic Language) were
developed mainly for scientific and engineering problems. Although one of the ideas
behind the development of ALGOL was that it was an appropriate language to define
algorithms. BASIC (Beginners All purpose Symbolic Instruction Code) was
developed to enable more people to write programs. All these languages follow the
procedural paradigm. That is, they describe, step by step, exactly the procedure that
should be followed to solve a problem.
The problem with procedural languages is that it can be difficult to reuse code and to
modify solutions when better methods of solution are developed. In order to address
these problems, object-oriented languages (like Eiffel, Smalltalk and Java) were
developed. In these languages, data and methods of manipulating the data, are kept as
4.5 - 1
2. a single unit called an object. The only way that a user can access the data is via the
object's methods. This means that, once an object is fully working, it cannot be
corrupted by the user. It also means that the internal workings of an object may be
changed without affecting any code that uses the object.
A further advance was made when declarative programming paradigms were
developed. In these languages the computer is told what the problem is, not how to
solve the problem. Given a database the computer searches for a solution. The
computer is not given a procedure to follow as in the languages discussed so far.
3.5 (b) Programming Paradigms and examples.
Procedural languages specify, exactly, the steps required to solve a problem. These
languages use the constructs: sequence, selection and repetition (see Section 1.3 in the
AS text). For example, to find the area of a rectangle the steps are
1. Read the length
2. Read the breadth
3. Multiply the length by the breadth
4. Output the result
In C++ this can be coded as
cout << "Enter the length: ";
cin >> Length;
cout << "Enter the breadth: ";
cin >> Breadth;
Area = Length * Breadth;
cout << "The area is "
<< Area << endl;
Here each line of code is executed one after the other in sequence.
Most procedural languages have two methods of selection. These are the IF …
THEN … ELSE statement and the SWITCH or CASE statement. For example, in
C++, we have
IF (Number > 0)
cout << "The number is positive.";
ELSE
{
IF (Number = = 0)
cout << "The number is zero.";
ELSE
cout << "The number is negative.";
}
4.5 - 2
3. In C++ multiple selections can be programmed using the SWITCH statement. For
example, suppose a user enters a single letter and the output depends on that letter, a
typical piece of code could be
switch (UserChoice)
{
case 'A':
cout << "A is for Apple.";
break;
case 'B':
cout << "B is for Banana.";
break;
case 'C':
cout << "C is for Cat.";
break;
default:
cout << "I don't recognise that letter.";
}
Repetition (or iteration) is another standard construct. Most procedural languages
have many forms of this construct such as
FOR … NEXT
REPEAT … UNTIL …
WHILE … ENDWHILE
A typical use of a loop is to add a series of numbers. The following pieces of C++
code add the first ten positive integers.
//Using a FOR loop
Sum = 0;
FOR (int i = 1; i <= 10; i++)
{
Sum = Sum + i;
}
cout << "The sum is "
<< Sum;
//Using a WHILE loop
Sum = 0;
i = 1;
while (i <= 10)
{
Sum = Sum + i;
i++;
}
cout << "The sum is "
<< Sum;
4.5 - 3
4. In procedural languages is that the programmer has to specify exactly what the
computer is to do.
Another programming paradigm is the declarative one. Declarative languages tell the
computer what is wanted but do not provide the details of how to do it. These
languages are particularly useful when solving problems in artificial intelligence such
as medical diagnosis, fault finding in equipment and oil exploration. The method is
also used in robot control. An example of a declarative language is Prolog. The idea
behind declarative languages is shown in Fig. 3.5.b.1.
User Search Engine Database
Fig. 3.5.b.1
Here the user inputs a query to the search engine, which then searches the database for
the answers and returns them to the user. For example, using Prolog, suppose the
database is
female(jane).
female(anne).
female(sandip).
male(charnjit).
male(jaz).
male(tom).
Note that in Prolog values start with a lowercase letter and variables start with an
uppercase letter. A user may want to know the names of all the males. The query
male(X).
will return
X = charnjit
X = jaz
X = tom
Notice that the user does not have to tell Prolog how to search for the values of X that
satisfy the query. This is fairly straightforward. However, suppose we now add to the
Prolog database the following data.
parent(jane,mary).
parent(jane, rajinder).
parent(charnjit, mary).
parent(charnjit, rajinder).
parent(sandip, atif).
4.5 - 4
5. parent(jaz, atif).
and suppose we wish to know the name of the mother of Atif. In Prolog we use the
query
parent(X, atif), female(X).
Prolog will output
X = sandip
Try writing a Visual Basic program to do this.
To get a list of all the fathers, we can simply write
parent(X, Y), male(X).
The result is
X = charnjit Y = mary
X = charnjit Y = rajinder
X = jaz Y = atif
If we only want a list of fathers we use the underscore and create the query
parent(X, _ ), male(X).
and the result is
X = charnjit
X = charnjit
X = jaz
3.5 (d) Standard Programming Techniques.
Let us consider how data can be input to a function or procedure. This is done by
means of parameters. The function below, written in Visual Basic, finds the perimeter
of a rectangle given its length and breadth. This is not the only way of finding the
perimeter and it probably is not the best way. However, it has been written like this in
order to illustrate certain programming points.
Public Function PerimeterOfRectangle(X As Integer, Y As Integer) As Integer
X=2*X
Y=2*Y
PerimeterOfRectangle = X + Y
End Function
4.5 - 5
6. In this function X and Y are integers the values of which must be passed to the
function before it can find the area of the rectangle. These variables are called formal
parameters. To use this function, another program will have to call it and provide the
values for X and Y. This can be done by means of a statement of the form
Perimeter = PerimeterOfRectangle(4, 6)
or we can use
A=3
B=4
Perimeter = PerimeterOfRectangle(A, B)
In both of these statements the variables inside the parentheses ( 4 and 6 in the first
example and A and B in the second) are called actual parameters.
Visual Basic is said to pass parameters by reference (or address) and C++ passes them
by value. It is interesting to see the effect of passing values by address. Here is the
function described above and a copy of the calling function in Visual Basic.
Public Function PerimeterOfRectangle(X As Integer, Y As Integer) As Integer
X=2*X
Y=2*Y
PerimeterOfRectangle = X + Y
End Function
Private Sub cmdShow_Click()
Dim A As Integer
Dim B As Integer
Dim Perimeter As Integer
A=3
B=4
picResults.Print "Before call to Sub A = "; A; " and B = "; B
Perimeter = PerimeterOfRectangle(A, B)
picResults.Print "Perimeter = "; Perimeter
picResults.Print "After call to Sub A = "; A; " and B = "; B;
End Sub
Fig.3.5.d.3 shows the output when this program is run.
4.5 - 6
7. Fig.3.5.d.3
Notice that after the function has been run the values of A and B have changed. This
is because the addresses of A and B were passed not their actual values.
Visual Basic can pass parameters by value and C++ can pass parameters by reference.
In Visual Basic we have to use the ByVal key word if we want values to be passed by
value. Here is a modified form of the Visual Basic function together with the output
from running the modified program.
Public Function PerimeterOfRectangle(ByVal X As Integer, ByVal Y As
Integer) As Integer
X=2*X
Y=2*Y
PerimeterOfRectangle = X + Y
End Function
Fig. 3.5.d.4
4.5 - 7
8. 3.5 (f) Object-Oriented Programming (OOP)
Person Class name
name
Data
address
outputData( )
getName( ) Methods
getAddress( )
Fig. 3.5.f.2
Now suppose we want a class Employee that requires the same data and methods as
Person and also needs to store and output an employee's National Insurance number.
Clearly, we do not wish to rewrite the contents of the class person. We can do this by
creating a class called Employee that inherits all the details of the class Person and
adds on the extra data and methods needed. This is shown in Fig. 3.5.f.3 where the
arrow signifies that Employee inherits the data and methods provided by the class
Person. Person is called the super-class of Employee and Employee is the derived
class from Person. An object of type Employee can use the methods provided by
Employee and those provided by Person.
Person
name
address
outputData( )
getName( )
getAddress( )
Employee
NINumber
outputData( )
getNINumber( )
Fig. 3.5.f.3
4.5 - 8
9. Notice that we now have two methods with the same name. How does the program
determine which one to use? If myPerson is an instantiation of the Person class, then
myPerson.outputData( );
will use the outputData( ) method from the Person class. The statement
myEmp.outputData( );
will use the method outputData( ) from the Employee class if myEmp is an
instantiation of the Employee class.
The concept of a method having two different meanings is called polymorphism.
Now suppose we have two types of employee; one is hourly paid and the other is paid
a salary. Both of these require the data and methods of the classes Person and
Employee but they also need different data to one another. This is shown in Fig.
3.5.f.4.
Person
name
address
outputData( )
getName( )
getAddress( )
Employee
NINumber
outputData( )
getNINumber( )
HourlyPaidEmp SalariedEmp
hourlyRate salary
outputData( ) outputData( )
getHourlyRate( ) 4.5 - 9 getSalary( )
10. How can an object of type Employee output the name and address as well as the N.I.
number? The outputData( ) method in class Employee can refer to the outputData( )
method of its superclass. This is done by writing a method, in class Employee, of the
form
void outputData( ) {
super.outputData( );
System.out.println("The N.I. number is " + NINumber);
}//end of outputData method.
Here super. outputData( ) calls the outputData( ) method of the super-class and then
outputs the N.I. number. Similarly, the other derived classes can call the methods of
their super classes.
Definitions
Data encapsulation is the combining together of the variables and the methods that
can operate on the variables so that the methods are the only ways of using the
variables..
A class describes the variables and methods appropriate to some real-world entity.
An object is an instance of a class and is an actual real-world entity.
Inheritance is the ability of a class to use the variables and methods of a class from
which the new class is derived.
3.5 (g) Declarative Languages
In Section 4.5.1, we saw that, in declarative languages, the programmer can simply
state what is wanted having declared a set of facts and rules. We now look at how
this works using examples of Prolog scripts. In order to do this, we shall use the
following facts.
female(jane).
female(anne).
female(sandip).
male(charnjit).
male(jaz).
male(tom).
parent(jane,mary).
parent(jane, rajinder).
parent(charnjit, mary).
parent(charnjit, rajinder).
parent(sandip, atif).
4.5 - 10
11. parent(jaz, atif).
Remember that variables must start with an uppercase letter; constants start with a
lowercase letter.
Suppose we ask
male(X).
Prolog starts searching the database and finds male(charnjit) matches male(X) if X is
given the value charnjit. We say that X is instantiated to charnjit. Prolog now
outputs
X = charnjit
Prolog then goes back to the database and continues its search. It finds male(jaz) so
outputs
X = jaz
and again continues its search. It continues in this way until the whole database has
been searched. The complete output is
X = charnjit
X = jaz
X = tom
No
The last line means that there are no more solutions.
The query male(X) is known as a goal to be tested. That is, the goal is to find all X
that satisfy male(X). If Prolog finds a match, we say that the search has succeeded
and the goal is true. When the goal is true, Prolog outputs the corresponding values of
the variables.
Now we shall add the rule
father(X, Y) :- parent(X, Y), male(X).
This rule states that X is father of Y if (the :- symbol) X is a parent of Y AND (the
comma) X is male.
The database now looks like this.
female(jane).
female(anne).
female(sandip).
male(charnjit).
male(jaz).
male(tom).
parent(jane,mary).
4.5 - 11
12. parent(jane, rajinder).
parent(charnjit, mary).
parent(charnjit, rajinder).
parent(sandip, atif).
parent(jaz, atif).
father(X, Y) :- parent(X, Y), male(X).
Suppose our goal is to find the father of rajinder. That is, our goal is to find all X that
satisfy
father(X, rajinder).
In the database and the rule the components female, male, parent and father are called
predicates and the values inside the parentheses are called arguments. Prolog now
looks for the predicate father and finds the rule
father(X, Y) :- parent(X, Y), male(X).
In this rule Y is instantiated to rajinder and Prolog starts to search the data base for
parent(X, rajinder)
This is the new goal. Prolog finds the match
parent(jane, rajinder)
if X is instantiated to jane. Prolog now uses the second part of the rule
male(X)
with X = jane. That is, Prolog's new goal is male(jane) which fails. Prolog does not
give up at this stage but backtracks to the match
parent(jane, rajinder)
and starts again, from this point in the database, to try to match the goal
parent(X, rajinder)
This time Prolog finds the match
parent(charnjit, rajinder)
with X instantiated to charnjit. The next step is to try to satisfy the goal
male(charnjit)
This is successful so
parent(charnjit, rajinder) and male(charnjit)
4.5 - 12
13. are true. Thus father(charnjit, rajinder) is true and Prolog returns
X = charnjit
Prolog continues to see if there are any more matches. There are no more matches so
Prolog outputs
No
Definitions: Instantiation is giving a variable in a statement a value.
Predicate logic is a branch of mathematics that manipulates logical statements that
can be either True or False.
A goal is a statement that we are trying to prove whether or not it is True or False.
3.5 (i) Third and Fourth Generation Languages
Third generation languages are those that use a structured syntax such as C, C++ and
Pascal. Early versions of Fortran and BASIC were not structured and are usually
treated as second generation languages. However, Visual Basic is structured and can
be treated as a third generation language.
Third generation languages need the user to specify clearly all the steps that need to
be taken to solve a problem. Fourth generation languages do not do this. Languages
that accompany modern database, word processing and spreadsheet packages do not
need the user to do this. The users of these packages tell the application what they
want to do not how to do it. An example is mail merge . Here all the user has to do is
tell the software what table or database to use and the mail merge will take place.
Databases often use query by example (QBE). Here the user simply states what is
required and the software will do the task. For example, Microsoft Access lets a user
specify conditions such as DOB < 01/01/90 and the necessary coding will be done. In
fact Access uses the Structured Query Language (SQL) to create the queries.
Consider the following table called Students.
name height weight
Alan 150 31.2
Brenda 140 27.8
Charnjit 148 30.7
Dalvinder 152 32.8
Elmira 143 28.1
Frank 158 33.4
Georgina 151 28.2
Now suppose we wish to find the names of all those students who have a height
greater than 150. In Access we could simply create a query with columns for name
and height and in the height column we would write
> 150
4.5 - 13
14. for the criteria. We could also specify, by means of a check box, that only the name
should be printed. The result would be
Dalvinder
Frank
Georgina
In fact, we can write the query in SQL as
SELECT name
FROM Students
WHERE height > 150;
This is what Access does.
Notice that we do not have to give the steps needed to check each entry in the table
Students. A more complicated query is
SELECT name
FROM Students
WHERE height > 145
AND
weight > 32;
Again, we do not tell the computer exactly how to find the answer required as we
would with a third generation language.
The development of fourth generation languages has meant that people who are not
programmers can produce useful results.
3.5 (j) Backus Naur Form and Syntax Diagrams
Since all programming languages have to be translated to machine code by means of a
computer, they must be clearly defined. Each statement must be of a prescribed form.
An example of the start of a FOR loop in Visual Basic is
For count = 1 To 10
but C++ expects
for (count = 1, count <= 10, count++)
A Visual Basic compiler would not understand the C++ syntax and vice versa. We
therefore need, for each language, a set of rules that specify precisely every part of the
language. These rules are specified using Backus Naur Form (BNF) or syntax
diagrams.
All languages use integers, so we shall start with the definition of an integer. An
integer is a sequence of the digits 0, 1, 2, … , 9. Now the number of digits in an
4.5 - 14
15. integer is arbitrary. That is, it can be any number. A particular compiler will restrict
the number of digits only because of the storage space set aside for an integer. But a
computer language does not restrict the number of digits. Thus the following are all
valid integers.
0
2
415
3040513002976
0000000123
Thus, an integer can be a single digit. We can write this as
<integer> ::= <digit>
This is read 'an integer is defined to be (::=) a digit'.
But we must now define a digit. A digit is 0 or 1 or 2 or … or 9 and we write this as
<digit> ::= 0|1|2|3|4|5|6|7|8|9
where the vertical line is read as OR. Notice that all the digits have to be specified and
that they are not inside angle brackets (< and >) like <integer> and <digit>. This is
because integer and digit have definitions elsewhere; the digits 0, 1, 2, … , 9 do not.
Our full definition of a single digit integer is
<integer> ::= <digit>
<digit> ::= 0|1|2|3|4|5|6|7|8|9
This is called Backus Naur Form (BNF).
But how are we going to specify integers of any length? Consider the integer
147
This is a single digit integer ( 1 ) followed by the integer 47. But 47 is a single digit
integer ( 4 ) followed by a single digit integer ( 7 ). Thus, all integers of more than
one digit start with a single digit and are followed by an integer. Eventually the final
integer is a single digit integer. Thus, an indefinitely long integer is defined as
<integer> ::= <digit><integer>
This is a recursive definition as integer is defined in terms of itself. Applying this
definition several times produces the sequence
<integer> ::= <digit><integer>
=<digit><digit><integer>
4.5 - 15
16. =<digit><digit><digit><integer>
To stop this we use the fact that, eventually, <integer> is a single digit and write
<integer> ::= <digit>|<digit><integer>
That is, <integer> is a <digit> OR a <digit> followed by an <integer>. This means
that at any time <integer> can be replaced by <digit> and the recursion stops. Strictly
speaking we have defined an unsigned integer as we have not allowed a leading plus
sign ( + ) or minus sign ( - ). This will be dealt with later. We now have the full
definition of an unsigned integer which, in BNF, is
<unsigned integer> ::= <digit>|<digit><unsigned integer>
<digit> ::= 0|1|2|3|4|5|6|7|8|9
This definition of an unsigned integer can also be described by means of syntax
diagrams as shown in Fig. 3.5.k.1.
integer digit
digit 0
1
2
3
4
5
6
7
8
9
Fig. 3.5.j.1
Now we shall define a signed integer such as
+27
-3415
4.5 - 16
17. This is simply an unsigned integer preceded by a + or – sign. Thus
<signed integer> ::= + <unsigned integer>| - <unsigned integer>
and we can use the earlier definition of an <unsigned integer>. It is usual to say that
an integer is an unsigned integer or a signed integer. If we do this we get the
following definition, in BNF, of an integer.
<integer> ::= <unsigned integer>|<signed integer>
<signed integer> ::= + <unsigned integer>| - <unsigned integer>
<unsigned integer> ::= <digit>|<digit><unsigned integer>
<digit> ::= 0|1|2|3|4|5|6|7|8|9
There are other valid ways of writing these definitions. However, it is better to use
several definitions than try to put all the possibilities into a single definition. In other
words, try to start at the top with a general definition and then try to break the
definitions down into simpler and simpler ones. That is, we have used top-down
design when creating these definitions. We have broken the definitions down until we
have terms whose values can be easily determined.
Fig. 3.5.j.2 shows the corresponding syntax diagrams.
integer
digit
+
-
digit
0
1
2
3
4
5
6
7
8
9
4.5 - 17
18. Care must be taken when positioning the recursion in the definitions using BNF.
Suppose we define a variable as a sequence of one or more characters starting with a
letter. The characters can be any letter, digit or the underscore. Valid examples are
A
x
sum
total24
mass_of_product
MyAge
Let us see what happens if we use a similar definition to that for an unsigned integer.
<variable> ::= <letter>|<character><variable>
<character> ::= <letter>|<digit>|<under-score>
Now 2Sum is valid as we use
<character><variable>
with <character> = 2 and <variable> = Sum. Continuing in this way we use 2, S and
u for <character> and then m for <letter>. This means that our definition simply
means that we must end with a letter not start with one. We must rewrite our
definition in such a way as to ensure that the first character is a letter. Moving the
recursive call to the front of <character> can do this. This means that the last time it
is called it will be a letter and this will be at the head of the variable. The correct
definition is
<variable> ::= <letter>|<variable><character>
<character> ::= <letter>|<digit>|<under-score>
<letter> ::= <uppercase>|<lowercase>
<uppercase> ::= A|B|C|D|E|F|G|H|I|J|K|ZL|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
<lowercase> ::= a|b|c|d|e|f|g|h|i|j|k|zl|m|n|o|p|q|r|s|t|u|v|w|x|y|z
<digit> ::= 0|1|2|3|4|5|6|7|8|9
<under-score> ::= _
A syntax diagram can also represent this. This is left as an exercise. You should also
note that, in the definition of integer, we used tail recursion, but here we have used
head recursion.
Let us now use our definition of an integer to define a real number such as
0.347
-2.862
+14.34
00235.006
The result is very simple, it is
<real number> ::= <integer> . <unsigned integer>
4.5 - 18
19. Finally, suppose we do not want to allow leading zeros in our integers. That is
00135 is not allowed
0 is allowed.
This means that an integer can be a
zero digit
non-zero digit
non-zero digit followed by any digit.
This means that an integer is
zero or digits
where digits must start with a non-zero digit. In BNF, this is
<integer> ::= <zero>|<digits>
<digits> must be a single non-zero digit or a non-zero digit followed by any digits.
This gives us
<digits> ::= <non-zero digit>|<digits><digit>
where
<zero> ::= 0
<non-zero integer> ::= 1|2|3|4|5|6|7|8|9
<digit> ::= <zero>|<non-zero digit>
Fig. 3.5.j.4 shows the corresponding syntax diagram.
4.5 - 19