Chapter #2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

function

(1) In programming, a named section of a program that performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

Name the four parts of a function

1.) return type 2.) name 3.) parameter list 4.) function body

What is the purpose of the #include directive?

> #include is a preprocesser directive, as the word itself suggests. >It is used to tell the compiler to include all the functions, and contents from a header file >In case of c such predefind function are developed by the programmers. if we need to use those function we have to call those predefined codes in our programs. We are doing that by using #include directive. >Good developers avoid unnecessary #include from programs. If you add one #include function then that program also added in your coded programs so it will take that much time for compilation also.

compile-time error

A compile time error is an error that is detected by the compiler. A program with a compile-time error cannot be compiled successfully until the error is corrected.

executable

A file in a format that the computer can directly execute. Unlike source files, executable files cannot be read by humans. To transform a source file into an executable file, you need to pass it through a compiler or assembler.

output

A result produced by a computer that is internal to the system (from one program or process to another) or external to it (from a program or process to an output device) but internal to an output device (modem, monitor, printer, etc.)

translation units

According to standard C++: A translation unit is the basic unit of compilation in C++. It consists of the contents of a single source file, plus the contents of any header files directly or indirectly included by it, minus those lines that were ignored using conditional preprocessing statements. A single translation unit can be compiled into an object file, library, or executable program.

run-time errors

An error that occurs during the execution of a program. Run-time errors indicate bugs in the program or problems that the designers had anticipated but could do nothing about. For example, running out of memory will often cause a run-time error.

IDE

An integrated development environment (IDE) is a programming environment that has been packaged as an application program, typically consisting of a code editor, a compiler, a debugger, and a graphical user interface (GUI) builder. The IDE may be a standalone application or may be included as part of one or more existing and compatible applications.

program

An organized list of instructions that, when executed, causes the computer to behave in a predetermined manner. Without programs, computers are useless. A program contains a list of variables (ingredients) and a list of statements (directions) that tell the computer what to do with the variables. The variables can represent numeric data, text, or graphical images.

C++

C++ is an object oriented programming (OOP) language, developed by Bjarne Stroustrup, and is an extension of C language.

definition

Defining something means providing all of the necessary information to create that thing in its entirety. Defining a function means providing a function body; defining a class means giving all of the methods of the class and the fields. Once something is defined, that also counts as declaring it; so you can often both declare and define a function, class or variable at the same time. But you don't have to.

link-time errors

If you receive a linker error, it means that your code compiles fine, but that some function or library that is needed cannot be found. This occurs in what we call the linking stage and will prevent an executable from being generated. Many compilers do both the compiling and this linking stage.

statement

In computer programming a statement is the smallest standalone element of an imperative programming language that expresses some action to be carried out. It is an instruction written in a high-level language that commands the computer to perform a specified action.[1] A program written in such a language is formed by a sequence of one or more statements. A statement may have internal components (e.g., expressions). Many languages (e.g. C) make a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier, while an expression evaluates to a value only.[2] A distinction can also be made between simple and compound statements; the latter may contain statements as components.

logic errors

In computer programming, a logic error is a bug in a program that causes it to operate incorrectly, but not to terminate abnormally (or crash). A logic error produces unintended or undesired output or other behaviour, although it may not immediately be recognised as such.

return type

In computer programming, a return statement causes execution to leave the current subroutine and resume at the point in the code immediately after where the subroutine was called, known as its return address.

library

In computer science, a library is a collection of implementations of behavior, written in terms of a language, that has a well-defined interface by which the behavior is invoked. This means that as long as a higher level program uses a library to make system calls, it does not need to be re-written to implement those system calls over and over again. In addition, the behavior is provided for reuse by multiple independent programs. A program invokes the library-provided behavior via a mechanism of the language. For example, in a simple imperative language such as C, the behavior in a library is invoked by using C's normal function-call. What distinguishes the call as being to a library, versus being to another function in the same program, is the way that the code is organized in the system. Library code is organized in such a way that it can be used by multiple programs that have no connection to each other, while code that is part of a program is organized to only be used within that one program. This distinction can gain a hierarchical notion when a program grows large, such as a multi-million-line program. In that case, there may be internal libraries that are reused by independent sub-portions of the large program. The distinguishing feature is that a library is organized for the purposes of being reused by independent programs or sub-programs, and the user only needs to know the interface, and not the internal details of the library.

linker

In computer science, a linker or link editor is a computer program that takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.

debugging

In computers, debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. To debug a program or hardware device is to start with a problem, isolate the source of the problem, and then fix it. A user of a program that does not know how to fix the problem may learn enough about the problem to be able to avoid it until it is permanently fixed. When someone says they've debugged a program or "worked the bugs out" of a program, they imply that they fixed it so that the bugs no longer exist.

source code

In computing, source code is any collection of computer instructions (possibly with comments) written using some human-readable computer language, usually as text. The source code of a program is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source code. The source code is often transformed by a compiler program into low-level machine code understood by the computer. The machine code might then be stored for execution at a later time. Alternatively, an interpreter can be used to analyze and perform the outcomes of the source code program directly on the fly. Most computer applications are distributed in a form that includes executable files, but not their source code. If the source code were included, it would be useful to a user, programmer, or system administrator, who may wish to modify the program or to understand how it works.

What is the purpose of line return 0?

In every C program you have to use return return 0; (or return -1;, or whatever... ), because the main function signature requires it. In a C++ program the statement is optional: the compiler automatically adds a return 0; if you don't explicitely return a value. The return value is the exit code of your program, the shell (or any other application that ran it) can read and use it. The 0 exit code is a widely accepted convention for 'OK the program execution was successfull'.

keyword

In programming, a keyword is a word that is reserved by a program because the word has a special meaning. Keywords can be commands or parameters.

machine code

Machine code, also called machine language, is a computer language that is directly understandable by a computer's CPU (central processing unit), and it is the language into which all programs must be converted before they can be run. Each CPU type has its own machine language, although they are basically fairly similar.

object code

Object code, or sometimes an object module, is what a computer compiler produces.[1] In a general sense object code is a sequence of statements or instructions in a computer language,[2] usually a machine code language (i.e., binary) or an intermediate language such as RTL. Object files can in turn be linked to form an executable file or library file. In order to be used, object code must either be placed in an executable file, a library file, or an object file. Object code is a portion of machine code that has not yet been linked into a complete program.

<<

Output operator.

cout

Pronounced "see-out", the name cout is an abbreviation of "character output stream." It refers to standard output stream. Prints to the screen.

main()

The main function must be declared as a non-member function in the global namespace. This means that it cannot be a static or non-static member function of a class, nor can it be placed in a namespace (even the unnamed namespace). The name main is not reserved in C++ except as a function in the global namespace. You are free to declare other entities named main, including among other things, classes, variables, enumerations, member functions, and non-member functions not in the global namespace. You can declare a function named main as a member function or in a namespace, but such a function would not be the main function that designates where the program starts. The main function cannot be declared as static or inline. It also cannot be overloaded; there can be only one function named main in the global namespace. The main function cannot be used in your program: you are not allowed to call the main function from anywhere in your code, nor are you allowed to take its address. The return type of main must be int. No other return type is allowed (this rule is in bold because it is very common to see incorrect programs that declare main with a return type of void; this is probably the most frequently violated rule concerning the main function). see: http://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main

parameter list

The parameter list is a (possibly empty) list of parameter declarations. Recall that a parameter is simply a local variable whose initial value is provided by the corresponding argument in the method call. If more than one parameter is declared in a method's parameter list, a comma ',' is used to separate the declarations. The parameter list is delimited by parentheses, '(' and ')'.

header

The portion of a data block, cell, frame, or packet that precedes the text field or payload and provides information such as the source address and destination address. The header often includes synchronization bits that serve to synchronize the operations of the transmit and receive devices across the link. Certain data protocols also use fields in the header to identify the length of the text field and the type of data, to indicate the level of tolerance for delay or loss during network transit, and any optional headers that might follow.

declaration

When you declare a variable, a function, or even a class all you are doing is saying: there is something with this name, and it has this type. The compiler can then handle most (but not all) uses of that name without needing the full definition of that name. Declaring a value--without defining it--allows you to write code that the compiler can understand without having to put all of the details. This is particularly useful if you are working with multiple source files, and you need to use a function in multiple files. You don't want to put the body of the function in multiple files, but you do need to provide a declaration for it.

compiler

a program that turns source code into object code

//

anything written after // on a line is a comment

function body

enclosed in a set of "curly braces," { }, it lists the actions (called statements) that the function is to perform.

comment

text that is ignored by the compiler and written for the benefit of programmers who read the code.


Kaugnay na mga set ng pag-aaral

Tema 7: La Segunda Guerra Mundial

View Set

AP Statistics Semester 2 Quiz/Checkpoint Questions

View Set

Chapter 23 - Functions of the Liver

View Set

intro to marketing: chapter 10 questions

View Set

Data Analysis: Descriptive and Inferential Statistics -Chapter 14

View Set

2.1 Binary/Decimal/Hexadecimal Conversion

View Set

Attempting to Break the Stalemate

View Set

3 | Chapter 7: The Muscular System

View Set

Unit 15 - Ethics, Recommendations, & Taxation

View Set

AWS Certified Cloud Practitioner Study

View Set