Programming

Python Programming

The History of Programming Languages

PHP-MySQL-Tutorial by khairul





Introduction to C++...

WHAT IS A PROGRAM?
Programs are sequence of step by step instructions to the computer. Programs, and the data values processed by programs, are called software.
PROGRAMMING LANGUAGES

Low-Level Programming Languages

* Machine language
*Assembly language

High-Level Programming Languages

Instructions look more like English and Math. Generally result in multiple low level commands, for a single high level statement.Uses syntax resembling combination of mathematical notation and English Easy for humans to understand. Not understandable by machines, must be translated using a compiler or an interpreter. Programming tools such as integrated programming environment with a debugger are available to aid in programming process.

Machine Language
Executable by machines, almost incomprehensible to humans. Programming in machine language is very tedious and prone to errors.
Assembly Language
Mnemonics used for instruction codes and memory locations Not directly understandable by machine. They must be translated Easier for humans to use and still in use today.
Ex: ADD X, Y, Reg 1
ADD Reg 1, Z, Reg 2 STORE Reg 2 SUM.


Program Language Translation

Assemblers

Translate statement from assembly language to machine language. Generally use table look-up techniques

Interpreters

Translate and execute each high-level statement, one at a time

Compilers

Translate the entire high level language program, called the source code, to machine language and store the result. Machine language code produced by compilers is called object code

Problem Solving and Software Development

Development and Design
*Analyze the problem
*Develop a solution*Code the solution*Test and debug
Documentation##Internal documentation##
Comments – Notes to the reader of the program
Identifiers – should represent the information they hold or the task they define.
##External documentation##
User’s manual
Test plan
Design document
Maintenance
Correcting new problems
Adding new features
Modifications due to change in requirements

Control Structures

Sequence
Selection
Iteration
Invocation

***THINGS NOT TO FORGET ABOUT C++***

*Identifiers are used to name entities in C++.
*Identifiers start with a letter. Identifiers are a sequence of letters, digits, and underscore characters _ . Identifiers may not contain embedded blank spaces. Identifiers may not be a reserved word.
*A reserved word is a word which has a special meaning in C++ and cannot be redefined by the programmer.
*A standard identifier or keyword is a word which has a defined meaning in C++ but its use can be changed by the programmer.
*c++ is a CASE SENSITIVE LANGUAGE.A programming language is case sensitive if the language considers two identifiers to be different if they consist of the same characters in the same order except for variations in upper and lower case. Name name NAME would be three different identifiers in a language which is case sensitive.
*Make sure you have a closing brace for every opening brace in your program.

Escape Sequences


SPESIAL CHARACTERS


OPERATORS

#The sizeof operator determines the storage size of a particular value, type, or variable.
#The assignment operator is the equal sign = .The assignment operation can be used to store a value in a variable or to change the value stored in a variable.
#Addition +
#Subtraction -
#Multiplication *
#Division /
#Modulus Division %
#To obtain the integer remainder of the division of two integers use the modulus division operator %.
#The program then uses the extraction operator (>>) with the stream cin to obtain the value the user typed at the keyboard.
#insertion operator (<<)use to give outputs.

Let's do a simple c++ program.

#include

The header file iostream  must be included in any program that uses the cout object. This is because cout is not part of the “core” of the C++ language.An #include directive must always contain the name of a file. The preprocessor inserts the entire contents of the file into the program at the point it encounters the #include directive. The compiler doesn’t actually see the #include directive. Instead it sees the code that was inserted by the preprocessor, just as if the programmer had typed it there.

int main()

This is a function.
**********************************************************

Variable

The symbolic name (identifier) for a storage location which can change its value is a variable. Variables must be declared, before they can be given a value. When you declare a variable you specify its name and type. The declaration allocates the storage location of the appropriate size and associates the name and data type with that location.

Formatting Output

*Manipulators control the format of output.
*Manipulators are sent to cout the same as data is sent to cout.
*Some Manipulators take parameters (such as flags ) which follow the Manipulator and are enclosed in parentheses.
*Need to include the header file
*setw manipulator specifies the number of spaces (n) that will be used to display a value.
*If the specified space is too small C++ will ignore the field width manipulator.
*The setprecision manipulator determines the number of digits to be printed in a fixed point float number.
*The precision of a float number is the number of digits after the decimal point, when the fixed or scientific flags are set. The precision of a float number when the fixed or scientific flags are not set is the total number of digits.

Functions

Functions are separately written code to perform a particular task. They accept input, and return a single value.

RELATIONAL OPERATORS

A relational operator tests the relationship between two expressions. An expression may be a constant, a variable, a function invocation, or a computation involving operators. The result of a relational operation is either true or false
When an operator consists of two keystrokes there can be no space in between the symbols.
Beware : A common error is to use the assignment operator(=) instead of the equivalence operator(==). The expression (x = y) assigns the value of y to x and evaluates to true as long as y was not 0.
a program with VARIABLES...


Comments

Popular posts from this blog

Probability

අසම්භාව්‍ය සම්භාවිතාවතාව