Computer Programming

¡Supera tus tareas y exámenes ahora con Quizwiz!

Pre-processor directive

#include <iostream> using namespace std;

Logical operators

&& [and] || [or] ! [not] - The result of the operation of a logical operator is a boolean value either true or false.

bitwise operators

&, |, ^, ~, <<, >> - Works and perform bit-by-bit operation.

Relational Operators

(==, !=, <, >, <=, >=): an operator that computes a true or false value. The names corresponding to these operators are equality, inequality, less-than, greater-than, less-than-or-equal, greater-than-or-equal.

Arithmetic Operators

+, -, *, /, %, ++, --, ()

compound operators

+=, -=, *=, /=, %=. Also known as combined assignment operators and arithmetic assignment operators.

Block Comment

- (/*) Creates a block comment, computers will read the first (/*) and ignore all text until the final (*/). (for multiply line instructions or comments) - /* Block Comment */

explicit type conversion

- A cast, or explicit type conversion, is special programming instruction that specifies what data type to treat a variable as (or an intermediate calculation result) in a given expression. -There are several kinds of explicit conversion. checked, no check and bit pattern

Implicit type conversion

- A conversion performed by the compiler without programmers intervention - It is applied generally whenever differing data types are intermixed in an expression (mixed mode expression), so as not to lose information.

Character

- A data type is used for storing characters. - Typed as char

floating point

- A data type used for storing single-precision floating-point values or decimal values. - Typed as float.

Integer

- A data type used to store positive and negative whole numbers. -Typed as int

Flowchart

- A diagram that shows step-by-step progression through a procedure or system especially using connecting lines and a set of conventional symbols. - Each step in the sequence is noted within a diagram shape. - Steps are linked by connecting lines and directional arrows.

Character Set

- A list of the characters and the codes used to represent each one - Lowercase letters (a-z) - Uppercase letter (A-Z) - Digits (0-9) - Special Characters (+,-,*,/,=,(,),{,}...)

Procedure-oriented program

- A program designed by focusing on the major tasks that need to be performed. - Programmers must instruct the computer every step of the way, from the start of the task to its completion.

Object-oriented program

- A program designed by focusing on the objects that the program could use to accomplish its goal. - Uses interacting Objects

Assembler

- A program that translates an assembly-language program into machine code/low-level language.

Low-level language

- A programming language that is designed to be easy for a computer to execute; also called machine language or assembly language. - Often Cryptic and not human-readable - Examples are machine language and Assemble language.

High-level language

- A programming language that is human readable and provides the programmer with easy to understand abstractions. - Visual Basic, C, C++, Java.

Boolean

- A single value of either TRUE or FALSE -Typed as bool.

Run-time error

- A software error that occurs during the execution of the program.

Program statement

- A statement is a simple or compind expression that can actually produce some effect. - It is the meat of a program, specifying its actual behavior. Each statement must be terminated by a semicolon ;

Increment

- Adds 1 to its operand - //postfix form

Run real data

- After alpha testing is Finished.

Comment line

- All lines beginning with two slash signs (//) are considered comments and do not have any effect on the behavior of the program.

using namespace std;

- All the elements standard to C++ library are declared within what is called a namespace, the namespace with the name std (standard)

Data types

- All variables use data type during declaration to restrict the type of data to be stored. Therefore, we can say that data types are used to tell the variables the type of data it can store. - Whenever a variable is defined in C++, the compiler allocates some memory for that variable based on the data-type in which it is declared. - Format of data in a field, such as text, number, or date. - Every data type requires a different amount of memory.

Pseudocode

- An Algorithm written in normal human language statements to describe the logic and processing flow.

Syntax error

- An error in a program that makes it impossible to parse — and therefore impossible to interpret. - The most common error and incorrect use of programming language statements.

Types of operators

- Assignment Operator - Arithmetic Operators - Compound Operators - Relational Operators - Logical Operators

Requirement Analysis

- At this stage the programmers, designers and the clients discuss the needs of the user so it is clear what is required.

Machine language

- Binary code made up of 0s and 1s; usually this is data converted from a high-level language by a compiler. Often used as a synonym for low-level programming language. - 0 is OFF and 1 is ON. Example is 0110 0110 0110

sqrt

- Compute Square root - function(variable);

Program Development Cycle

- Consists of the steps that occur during a program's lifetime 1. Requirement Analysis 2. System Design 3. Coding or Writing the program 4. Testing and Validation 5. Documentation and Maintenance

wide character

- Data type is also a character data type but this data type has size greater than the normal 8-bit language. - Typed as wchar_t

Double floating point

- Data type is used for storing double precision floating point values or decimal values. Keyword used for double floating point data type is double

void

- Data type that represents no value entity. -Used for those function which does not return value.

Problem Analysis steps

- Define the Problem and users. - Determine the input to achieve the desired outputs. -Determine the process involve. - Check the feasibility of implementing the program. -Document the analysis.

Syntax

- Each programming language has its own grammar called syntax. - Consists of rules governing the structure and content of the statement that should be followed.

C++

- Extension of C - Statically typed, compiled, general-purpose, case sensitive, a free-form programming language that supports procedural, object-oriented, and generic programming. -Is regarded as a middle-level language, as it comprises

Primitive Data types

- Integer - Character - Boolean - Floating Point - Double Floating Point - Valueless or Void - Wide Character

Program

- Is a list of the sequence of instructions that tell a computer what to do. - Everything a computer does is done by using a computer program. -It is written in a programming language.

Source Code

- Is a well-written set of instructions and statements to develop a program. - It can be written in the low-level or high-level language. - Must be translated to machine language (binary form) using a language translator.

Maintenance

- Is any activity designed to keep programs error-free, up-to-date and in good working condition.

Standard input

- Is by default, is in the keyboard, C++ stream object defined to access it is cin. - For formatted input operations, cin is used together with the insertion operator, which is written as >> (i.e., two greater than signs)

Desk Checking

- Is manually testing the solution design to make sure that it is free of errors and that logic works.

Identifiers

- It is a name used to identify a variable, function, class, module, or any other user-defined item. -Starts with letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 - 9). -C++ does not allow punctuation characters such as @, $, and %. C++ is a case-sensitive programming language. -Thus, Manpower and manpower are different in here.

Documentation

- It is a written detailed description of the programming cycle and specific facts about the program. - It includes necessary instructions on the use and maintenance of the program/software (product).

Variables

- It is also known as user-defined identifier. It is data storage location that has a value, which can change during program execution. - By using a variable's name in your program, you are, in effect referring to the data stored there. - You must initialize a variable - probably giving it a value of zero - before you use it in a calculation or you need to make sure that it is given a value in some other way. Otherwise, it contains a random number. - All variables in C++ must be declared prior to their use.

Standard Output

- It is by default, the screen, and the C++ stream object defined to access it is cout. - For formatted output operators, cout is used together with the insertion operator, which is written as << (i.e., two less than signs)

#define directive

- It is used to define symbolic names and constants Syntax: #define identifier string Examples: #define TRUE 1 #define PI 3.14159 #define NAME "SAM"

Line break

- New-line character shall be inserted at the exact position the line should be broken. - "\n";

C++ operators and expressions

- Operators are the symbols that tell the compiler to perform specific mathematical or logical manipulators.

Testing and Validation

- Program testing involves running various tests, such as desk checking and debugging - called alpha testing, and then running actual or real data to make sure the program works.

Assembly language

- Programming language that has the same structure and set of commands as machine languages but allows programmers to use symbolic representations of numeric machine code.

Programming language

- Provides the standards, syntax, statements, and instructions for writing computer software or program. - It is a type of written language that tells a computer what to do in order to work.

pow

- Raise to power - function(base, exponent);

Keywords

- Reserved words with special meaning in C++. - These are listed in Table 1 and must not be used as constant or variable or any other identifier names. - Remember that keywords in C++ are case sensitive and should be in lowercase. -Other names which you should not use as variables are the names of data types such as int, char, float.

ceil

- Round up value - function(variable);

trunc

- Rounds removes digits after decimal point - function(variable)

Construction of codes

- Select the appropriate programming language. -Follow the syntax.

setprecision

- Sets the decimal precision to be used to format the floating-point values on output operations. - cout << fixed << showpoint << setprecision(2);

Data type modifiers

- Signed - Unsigned - Short - Long

constant

- Something that stays the same _ Fixed value

Assignment Operator

- The '=' character causes the compiler or interpreter to evaluate to the expression on its right and store the result in the variable(s) on its left.

Coding

- The actual writing of the program based on the design specifications (coding) - The design specifications describe how a system performs the requirements.

int main()

- The function named main is a special function

#include <math.h>

- The math.h header defines various mathematical functions and one macro. -Examples: pow, sqrt

{ and }

- The open brace { indicates the beginning of main's function definition, and closing brace } indicated its end. - Everything between these braces in function's body defines what happend when main is called. - All functions are braces to indicate the beginning and end of their definitions.

Type Conversion (Casting)

- The process of converting one predefined type into another. This is also called type casting - When constants and variables of different types are mixed in an expression, they are converted to the same type. - When variables of one type are mixed with variables of another type, a type conversion will occur.

System Design

- The program design process the algorithm for the solution of the problem. - An Algorithm is the step-by-step sequence of instructions that describe how data will be processed to produce the desired output. - To formulate the algorithm, a programmer may choose between pseudocodes or flowcharts.

return 0;

- This defines the exit status of the process or application - It terminated main() function and causes it to return the value 0 to the calling process - It should end with semicolon ;

#include <iostream>

- This specific file (iostream) includes the declarations of the basic standard input-output library in C++ - Examples are cin, cout

Language Translators

- Translate programs are written by programmers to the language the computer understands. - These language translators are Assembler, Interpreter and Compiler.

Compiler

- Translates all statements at one time. It provides all the error messages - called diagnostics - at once. -Examples are C, C++ and Java

Interpreter

- Translates each statement or one line at a time and executed immediately after translation. -Examples are JavaScript, Python and Ruby.

insertion operator

- Two less-than signs (<<); used with the cout object to display information on the computer screen

Data modifiers

- Used with the built-in data types to modify the length of data that a particular data type can hold. Data type modifiers available in the C++ are Signed, Unsigned, Short and Long

Documentation and maintenance

- When the program is finalized, its documentation is prepared.

Programmer

- Writes source codes using a programming language to create software or programs.

Type Conversion (Casting) forms

- implicit type conversion and explicit type conversion

Logical error

- occurs when incorrect instructions are performed, or when instructions are performed in the wrong order.

floor

- round down value - function(variable)

round

- rounds given number to closest integer

Decrement

- subtracts 1 from its operand. -//prefix form

Conditional Operators

- symbols used to construct conditional expressions. -?, :

escape codes

- used to represent certain special characters within string literals and character literals. -examples are \n, \t etc.

Preprocessor directive

-Lines beginning with a hash or pound sign (#) are directives for the pre-processor. They tell the compiler to pre-process the source code before compiling. -No white space should appear before #, and semi colon is not required at the end. - Common examples are #include and #define

Debugging

-Means detecting, locating, and removing all errors in a computer program. - Finding and fixing problems in your algorithm or program.

Comment

//This is my first program in C++

Testing and Validation requires the following steps

1. Perform Desk-checking 2. Debug the program 3. Run real data

Type of errors

1. Syntax Errors 2. Run-time Errors 3. Logical Errors

Logical Order

All necessary requirements should be listed out

Pseudocode

An implementation of an algorithm in the form of annotations and informative text written in plain English and it is not standardized

Oblong

Beginning or End of the program (Terminator)

Flowchart should be:

Clear Neat Easy to flow

Diamon/Pentagon

Decision

Alpha testing

Desk Checking and Debugging

}

End of the program

Arrow up and down

Flow Lines

Common conditions used in Pseudocode

IF-THEN-ENDIF IF-ELSE IF-ENDIF IF-ELSE IF-ELSE-ENDIF CASE-OTHERS-ENDCASE

Hexagon

Initialization

Parallelogram

Input/Output

Pseudocode

It has no syntax like any of the programming language and thus can't be compiled or interpreted by the computer

int main()

Main Functions

Flag

Off-Page Connector

Circle

On-page connector

Top to Bottom

Order of execution of the statements

cout<<"Hello World";

Output statement

Rectangle

Process

return 0;

Return

Flowcharts can be used to express:

Sequence Selection/Conditional Loop

{

Start of the program

START

The start of pseudocode

INPUT, READ/GET

This is data retrieved from the user through typing or though an input device

PRINT, OUTPUT, DISPLAY, SHOW

This will show your output to a screen or relevant output device

Program Flowchart

a diagram that uses a set of standard graphic symbols to represent the sequence of coded instructions fed into a computer, enabling it to perform specified logical and arithmetical operations.

Algorithm

can be expressed using pseudocode or flowchart

Pseudocode

false code

Algorithm

is a procedure or formula for solving a problem, based on conducting a sequence of specified actions.

Usual direction of the flow

left to right; or top to bottom

Flowchart

pictorial representation of an ordered, step-by-step solution to a problem

Display, print, and store

refer to the computer screen, printer, and a file on a disk

Keywords

used to indicate common input-output and processing operations. WRITTEN FULLY IN UPPERCASE.

Input-Process-Output (IPO) chart

where algorithm is written in the processing column


Conjuntos de estudio relacionados

Introduction to Criminal Justice Chapter 8

View Set

Sociology Exam 1 (ch.1-6) Test Question Bank

View Set

Chapter 5 Reproduction Questions

View Set

Chapter 9: Cellular Respiration and Fermentation (Practice Test)

View Set

Advanced Accounting Exam #2 (Ch. 3 & 4)

View Set