assignment c++ adibah

6
QUESTIONS 1. Who is Written C++ ? Bjarne Strousstrup, a Danish computer scientist, began his work on C++'s predecessor "C with Classee" in 1979.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. 2. An example application in C++ Programming a) Go to Use of goto statement is highly discouraged because it makes difficult to trace the control flow of a program, making the program hard to understand and hard to modify. Any program that uses a goto can be rewritten so that it doesn't need the goto.

Upload: alif-najmi

Post on 12-Apr-2016

11 views

Category:

Documents


0 download

DESCRIPTION

Assignment c++

TRANSCRIPT

Page 1: ASSIGNMENT C++ adibah

QUESTIONS

1. Who is Written C++ ?

Bjarne Strousstrup, a Danish computer scientist, began his work on C++'s predecessor "C with Classee" in 1979.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.

2. An example application in C++ Programminga) Go to

Use of goto statement is highly discouraged because it makes difficult

to trace the control flow of a program, making the program hard to

understand and hard to modify. Any program that uses a goto can be

rewritten so that it doesn't need the goto.

Page 2: ASSIGNMENT C++ adibah

b) While

Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop checks its condition at the bottom of the loop.

A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.

Page 3: ASSIGNMENT C++ adibah

c) Break and Continue

There are two statements (break; and continue;) built in C++ programming to alter the

normal flow of program.

Loops are used to perform repetitive task until test expression is false but sometimes it is

desirable to skip some statement/s inside loop or terminate the loop immediately with

checking test condition. On these type of scenarios,  continue; statement

and break; statement is used respectively. Thebreak; statement is also used to terminate

switch statement.

Page 4: ASSIGNMENT C++ adibah

d) While true

A while loop statement repeatedly executes a target statement as long as a given condition is true.

e) Do / While

The do-while loop is an exit-condition loop. This means that the code must always be executed first and then the expression or test condition is evaluated. If it is true, the code executes the body of the loop again

Page 5: ASSIGNMENT C++ adibah

f) Jump / Loop

Loops are used to perform repetitive task until test expression is false but sometimes it is desirable to skip some statement/s inside loop or terminate the loop immediately with checking test condition. On these type of scenarios, continue; statement and break; statement is used respectively. Thebreak; statement is also used to terminate switch statement.

g) If / else

An if statement can be followed by an optional else statement, which executes when the boolean expression is false.

Page 6: ASSIGNMENT C++ adibah