4
Bjarne Stroustrup (Danish: born 30 December 1950) is a Danish computer scientist, most notable for the creation and development of the widely used C++ programming language.He is a Distinguished Research Professor and holds the College of Engineering Chair in Computer Science at Texas A&M University, is a visiting professor at Columbia University, and works at Morgan Stanley as a Managing Director in New York. 1. Stroustrup has a master's degree in mathematics and computer science (1975) from Aarhus University, Denmark, and a Ph.D. in computer science (1979) from the University of Cambridge, England. His thesis advisor in Cambridge was David Wheeler. 2. In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on the predecessor to C++, "C with Classes".[7] The motivation for creating a new language originated from Stroustrup's experience in programming for his Ph.D. thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level to be suitable for large software development. When Stroustrup started working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his Ph.D. experience, Stroustrup set out to enhance the C language with Simula-like features.[8] C was chosen because it was general-purpose, fast, portable and widely used. As well as C and Simula's influences, other languages also influenced C++, including ALGOL 68, Ada, CLU and ML. 3. Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining and default arguments.[9] 4. In 1983, C with Classes was renamed to C++ ("++" being the increment operator in C), adding new features that included virtual functions, function name and operator overloading, references, constants, type-safe free-store memory allocation (new/delete), improved type checking, and BCPL style single-line comments with two forward slashes (//). Furthermore, it included the development of a standalone compiler for C++, Cfront. 5. In 1985, the first edition of The C++ Programming Language was released, which became the definitive reference for the language, as there was not yet an official standard.[10] The first commercial implementation of C++ was released in October of the same year.[7] 6. In 1989, C++ 2.0 was released, followed by the updated second edition of The C++ Programming Language in 1991.[11] New features in 2.0 included multiple inheritance, abstract classes, static member functions, const member functions, and protected members. In 1990, The Annotated C++ Reference Manual was published. This work became the basis for the future standard. Later feature additions included templates, exceptions, namespaces, new casts, and a boolean type. 7. After the 2.0 update, C++ evolved relatively slowly until, in 2011, the C++11 standard was released, adding numerous new features, enlarging the standard library further, and providing more facilities to C++ programmers. After a minor C++14 update, released in December 2014, various new additions are planned for 2017

C++ Assing

Embed Size (px)

DESCRIPTION

Assingment C++

Citation preview

Bjarne Stroustrup (Danish: born 30 December 1950) is a Danish computer scientist, most

notable for the creation and development of the widely used C++ programming language.He is a

Distinguished Research Professor and holds the College of Engineering Chair in Computer

Science at Texas A&M University, is a visiting professor at Columbia University, and works

at Morgan Stanley as a Managing Director in New York.

1. Stroustrup has a master's

degree in mathematics and computer science (1975) from Aarhus

University, Denmark, and a Ph.D. in computer science (1979) from

the University of Cambridge, England. His thesis advisor in

Cambridge was David Wheeler.

2.

In 1979, Bjarne Stroustrup, a Danish computer scientist, began

work on the predecessor to C++, "C with Classes".[7] The

motivation for creating a new language originated from Stroustrup's

experience in programming for his Ph.D. thesis. Stroustrup found

that Simula had features that were very helpful for large software

development, but the language was too slow for practical use, while

BCPL was fast but too low-level to be suitable for large software

development. When Stroustrup started working in AT&T Bell Labs,

he had the problem of analyzing the UNIX kernel with respect to

distributed computing. Remembering his Ph.D. experience,

Stroustrup set out to enhance the C language with Simula-like

features.[8] C was chosen because it was general-purpose, fast,

portable and widely used. As well as C and Simula's influences,

other languages also influenced C++, including ALGOL 68, Ada,

CLU and ML.

3. Initially, Stroustrup's "C with Classes" added features to the

C compiler, Cpre, including classes, derived classes, strong typing,

inlining and default arguments.[9]

4. In 1983, C with Classes was renamed to C++ ("++" being the increment operator in C),

adding new features that included virtual functions, function name and operator

overloading, references, constants, type-safe free-store memory allocation (new/delete),

improved type checking, and BCPL style single-line comments with two forward slashes

(//). Furthermore, it included the development of a standalone compiler for C++, Cfront.

5. In 1985, the first edition of The C++ Programming Language was released, which

became the definitive reference for the language, as there was not yet an official

standard.[10] The first commercial implementation of C++ was released in October of the

same year.[7]

6. In 1989, C++ 2.0 was released, followed by the updated second edition of The C++

Programming Language in 1991.[11] New features in 2.0 included multiple inheritance,

abstract classes, static member functions, const member functions, and protected

members. In 1990, The Annotated C++ Reference Manual was published. This work

became the basis for the future standard. Later feature additions included templates,

exceptions, namespaces, new casts, and a boolean type.

7. After the 2.0 update, C++ evolved relatively slowly until, in 2011, the C++11 standard

was released, adding numerous new features, enlarging the standard library further, and

providing more facilities to C++ programmers. After a minor C++14 update, released in

December 2014, various new additions are planned for 2017

2. State statements below and give an example application in C + + Program.

a. Go to

The Go to statement unconditionally transfers control to the statement labeled by the

specified identifier.

The labeled statement designated by identifier must be in the current function.

All identifier names are members of an internal namespace and therefore do not interfere

with other identifiers.

A statement label is meaningful only to a Go to statement; otherwise, statement labels

are ignored. Labels cannot be redeclared.

EXAMPLE : Syntax goto identifier;

b. While

Executes statement repeatedly until expression evaluates to zero.

The test of expression takes place before each execution of the loop; therefore, a while loop

executes zero or more times. expression must be of an integral type, a pointer type, or a class

type with an unambiguous conversion to an integral or pointer type.

EXAMPLE : while( (pszEOS >= szSource) && (*pszEOS == '_') )

c. Break and Continue

Break

The break statement ends execution of the nearest enclosing loop or conditional statement in

which it appears. Control passes to the statement that follows the end of the statement, if any.

The break statement is used with the conditional switch statement and with the do, for,

and while loop statements.

In a switch statement, the break statement causes the program to execute the next

statement outside the switch statement. Without a breakstatement, every statement

from the matched case label to the end of the switch statement, including

the default clause, is executed.

In loops, the break statement ends execution of the nearest enclosing do, for,

or while statement. Control passes to the statement that follows the ended statement, if

any.

Within nested statements, the break statement ends only the do, for, switch,

or while statement that immediately encloses it. You can use a returnor goto statement

to transfer control from more deeply nested structures.

EXAMPLE : Syntax break;

Continue

Forces transfer of control to the controlling expression of the smallest enclosing do, for,

or while loop.Any remaining statements in the current iteration are not executed. The next

iteration of the loop is determined as follows:

In a do or while loop, the next iteration starts by reevaluating the controlling expression

of the do or while statement.

In a for loop (using the syntax for(init-expr; cond-expr; loop-expr)), the loop-expr clause is

executed. Then the cond-expr clause is reevaluated and, depending on the result, the loop

either ends or another iteration occurs

EXAMPLE : Syntax continue;

d. While True

These loops are used when one wants to loop forever and the breaking out

condition from loop is not known. Certiain conditions are set inside the loop along

with either break or return statements to come out of the loop

EXAMPLE : while( true ){

//run this code

If(condition satisfies)

break; //return;

e. Do / While

Executes a statement repeatedly until the specified termination condition (the expression)

evaluates to zero.

The test of the termination condition is made after each execution of the loop; therefore,

a do-while loop executes one or more times, depending on the value of the termination

expression. The do-while statement can also terminate when a break, goto,

or return statement is executed within the statement body.

1.The expression must have arithmetic or pointer type. Execution proceeds as follows:The

statement body is executed.

2.Next, expression is evaluated. If expression is false, the do-while statement terminates

and control passes to the next statement in the program. If expression is true (nonzero),

the process is repeated, beginning with step 1.

EXAMPLE : // do_while_statement.cpp

#include <stdio.h>

int main()

{

int i = 0;

do

{

printf_s("\n%d",i++);

} while (i < 3);

}

f. Jump / Loop

Jump Statement performs an immediate local transfer of control

Example : Syntax return [expression];

Loop statement repeatedly excutes a target statement as long as a given condition is

true

Example : Syntax while(condition)

{

Statement(s);

}

g. If / Else

Controls conditional branching.

If the value of expression is nonzero, statement1 is executed. If the optional else is

present, statement2 is executed if the value of expression is zero.expression must be of

arithmetic or pointer type, or it must be of a class type that defines an unambiguous

conversion to an arithmetic or pointer type.

In both forms of the if statement, expression, which can have any value except a structure,

is evaluated, including all side effects. Control passes from the if statement to the next

statement in the program unless one of the statements contains a break, continue,

or goto.

The else clause of an if...else statement is associated with the closest

previous if statement in the same scope that does not have a

correspondingelse statement.

For this sample to be unambiguous about if...else pairing, uncomment the braces.

EXAMPLE : if ( expression )

statement1

[else

statement2]