0% found this document useful (0 votes)
100 views8 pages

Assigment (Mohamad Akram)

Bjarne Stroustrup created and developed the C++ programming language. He began developing C++ in 1978 as an enhancement to the C language and chose its design criteria. Stroustrup wrote the early definitions of C++ and its first implementation. He is a professor at Texas A&M University and works at Morgan Stanley.

Uploaded by

akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views8 pages

Assigment (Mohamad Akram)

Bjarne Stroustrup created and developed the C++ programming language. He began developing C++ in 1978 as an enhancement to the C language and chose its design criteria. Stroustrup wrote the early definitions of C++ and its first implementation. He is a professor at Texas A&M University and works at Morgan Stanley.

Uploaded by

akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Who is written c ++?

Bjarne Stroustrups

His history : Bjarne Stroustrup (Danish: [bjn sd sdb];[2][3] born 30


December 1950) is a Danish computer scientist, most notable for the creation
and development of the widely used C++ programming language.[4] He is a
Distinguished Research Professor and holds the College of Engineering Chair in
Computer Science at Texas A&M University,[5] a visiting professor at Columbia
University, and works at Morgan Stanley. 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.[5] His thesis advisor in Cambridge was David Wheeler. 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."[11] 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.[12][13] He is also a
visiting faculty in Computer Science Department at Columbia University.[14]
ITMO University noble doctor since 2013. In 2015, he was made a Fellow [16] of
the Computer History Museum for his invention of the C++ programming
language.

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

a. Go to
A ) Go to : goto label;
... .. ...
... .. ...
... .. ...
label:
statement;
... .. ...
Reason to Avoid goto Statement
The goto statement gives power to jump to any part of program but,
makes the logic of the program complex and tangled. In modern
programming, goto statement is considered a harmful construct and a bad
programming practice.
The goto statement can be replaced in most of C++ program with the use
of break and continue statements.

B ) While:

float num1,num2;
cout<<"Select an operator either + or - or * or / \n";
cin>>o;
cout<<"Enter two operands: ";
cin>>num1>>num2;

switch(o) {
case '+':
cout<<num1<<" + "<<num2<<" = "<<num1+num2;
break;
case '-':
cout<<num1<<" - "<<num2<<" = "<<num1-num2;
break;
case '*':
cout<<num1<<" * "<<num2<<" = "<<num1*num2;
break;
case '/':
cout<<num1<<" / "<<num2<<" = "<<num1/num2;
break;
default:

/* If operator is other than +, -, * or /, error message is shown */


printf("Error! operator is not correct");
break;
}
return 0;
}
The value of n is either an integer or a character in above syntax. If the value of n
matches constant in case, the relevant codes are executed and control moves out of the
switch statement. If the n doesn't matches any of the constant in case, then the default
statement is executed and control moves out of switch statement

C ) Break:
// C++ Program to demonstrate working of break statement

#include <iostream>
using namespace std;
int main() {
float number, sum = 0.0;

while (true) {

// test expression is always true

cout<<"Enter a number: ";


cin>>number;

if (number != 0.0) {
sum += number;

}
else {
break; // terminating the loop if number equals to 0.0
}

}
cout<<"Sum = "<<sum;
return 0;
}
In this C++ program, the test expression is always true. The user is asked to enter a number
which is stored in variable number. If the user enters any number other than 0, that number is
added to sum and stored to it and again user is asked to enter another number. When user
enters 0, the test expression inside if statement is false and body of else is executed which
terminates the loop. Finally, the sum is displayed.

C ) Continue :
// C++ Program to demonstrate working of continue statement

#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 10; ++i) {
if ( i == 6 || i == 9) {
continue;
}
cout<<i<<"\t";
}
return 0;
}

D ) While True :
#include <iostream>

using namespace std;

int main() {
int number, i = 1, factorial = 1;
cout<< "Enter a positive integer: ";
cin >> number;

while ( i <= number) {


factorial *= i;

//factorial = factorial * i;

++i;
}

cout<<"Factorial of "<<number<<" = "<<factorial;


return 0;
}
The while loop checks whether the test expression is true or not. If it is true, code/s
inside the body of while loop is executed,that is, code/s inside the braces { } are
executed. Then again the test expression is checked whether test expression is true or
not. This process continues until the test expression becomes false.

E ) Do / While :
do {
statement/s;
}
while (test expression);

The statement/s inside body of loop is executed at least once, that is, the statement/s inside
braces { } is executed at least once. Then the test expression is checked. If the test expression
is true, the body of loop is executed. This process continues until the test expression becomes

false. Since the body of loop is placed before the test expression in do...while loop, the body
of loop is executed at least once.

F ) Jump / Loop :
for(initialization statement; test expression; update statement) {
code/s to be executed;
}
The initialization statement is executed only once at the beginning of the for loop.
Then the test expression is checked by the program. If the test expression is false, for
loop is terminated. But if test expression is true then the code/s inside body of for loop
is executed and then update expression is updated. This process repeats until test
expression is false.

G ) If / else :
if ( a < b ) {
a = b;
}
else {
a = -b;
}
The if...else executes body of if when the test expression is true and executes the body
of else if test expression is false

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy