Sie sind auf Seite 1von 6

ASSIGNMENT: C++ PROGRAMMING

QUESTIONS
1. Who is Written C++
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.
Education
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.
Career
Stroustrup began developing C++ in 1978 (then called "C with Classes"), and, in his
own words, "invented C++, wrote its early definitions, and produced its first
implementation... chose and formulated the design criteria for C++, designed all its
major facilities, and was responsible for the processing of extension proposals in the
C++ standards committee." Stroustrup also wrote a textbook for the language, The
C++ Programming Language.
Stroustrup was the head of AT&T Bell Labs' Large-scale Programming Research
department, from its creation until late 2002. Stroustrup was elected member of the
National Academy of Engineering in 2004. He is a Fellow of the ACM (1994) and an
IEEE Fellow. He works at Texas A&M University as a Distinguished Professor where
he holds the College of Engineering Endowed Chair in Computer Science. He is also a
visiting faculty in Computer Science Department at Columbia University. ITMO
University noble doctor since 2013
In 2015, he was made a Fellow of the Computer History Museum for his invention of
the C++ programming language.

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


program.
a. Go to
The goto statement unconditionally transfers control to the statement labeled by
the specified identifier.
SYNTAX of go to

Example go to

b. While
Executes statement repeatedly until expression evaluates to zero.

Syntax of while

Remarks
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.
A while loop can also terminate when a break, goto, or return within the
statement body is executed. Use continue to terminate the current iteration
without exiting the while loop. continue passes control to the next iteration of
the while loop.
The following code uses a while loop to trim trailing underscores from a string:

EXAMPLE While

c. Break and Continue


Break
The break; statement terminates the loop(for, while and do..while loop) and switch
statement immediately when it appears.

Syntax of Break

In real practice, break statement is almost always used inside the body of conditional
statement(if...else) inside the loop.
Working of break Statement

Example 1: C++ break


C++ program to add all number entered by user until user enters 0.

continue
It is sometimes necessary to skip some statement/s inside the loop. In that case, continue;
statement is used in C++ programming.

Syntax of continue

In practice, continue; statement is almost always used inside conditional statement.


Working of continue Statement

d.

While True
One is that some compilers produce warnings on while(true) (something like "loop condition
is constant"). Avoiding warnings is always a good thing to do.
Syntax of while true

Example

e. Do / while
In computer programming, loop cause a certain piece of program to be executed
a certain number of times. Consider these scenarios:
You want to execute some code/s certain number of time.
You want to execute some code/s certain number of times depending
upon input from user.
These types of task can be solved in programming using loops.
There are 3 types of loops in C++ Programming:
for Loop
while Loop
do...while Loop
Syntax of while Loop

Example

f. Jump / Loop
A C++ jump statement performs an immediate local transfer of control.
Syntax of jump

g. If / else
The if...else executes body of if when the test expression is true and
executes the body of else if test expression is false.
Working of if...else statement

Example 2: C++ if...else Statement


C++ Program to check whether integer entered by user is positive or negative
(Considering 0 as positive)

Das könnte Ihnen auch gefallen