Professional Documents
Culture Documents
QUESTION
1. Who is Written C++.
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.
# include <stdio.h>
int main(){
float num,average,sum;
int i,n;
scanf("%d",&n);
for(i=1;i<=n;++i){
scanf("%f",&num);
if(num<0.0)
goto jump;
jump */
sum=sum+num;
jump:
average=sum/(i-1);
printf("Average: %.2f",average);
B. While
Loops causes program to execute the certain block of code repeatedly until
some conditions are satisfied, i.e., loops are used in performing repetitive
work in programming.
Suppose you want to execute some code/s 10 times. You can perform it by
writing that code/s only one time and repeat the execution 10 times using
loop.
There are 3 types of loops in C programming:
statement/s to be executed.
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.
break Statement
The break statement can be used in terminating all three loops for, while and
do...while loops.
The figure below explains the working of break statement in all three
type of loops .
# include <stdio.h>
int main(){
float num,average,sum;
int i,n;
scanf("%d",&n);
for(i=1;i<=n;++i){
scanf("%f",&num);
if(num<0.0)
break;
sum=sum+num;
average=sum/(i-1);
printf("Average=%.2f",average);
return 0;
D. WHILE TRUE
The do...while Loop is similar to while loop with one very important difference.
Inwhile loop, check expression is checked at first before body of loop but in case
ofdo...while loop, body of loop is executed first then only test expression
ischecked. That's why the body of do...while loop is executed at least once.
E. Do/ While
One interesting thing about the while loop is that if the loop condition is
initially false, thewhile loop will not execute at all. It is sometimes the
case that we know we want a loop toexecute at least once, such as when
displaying a menu. To help facilitate this, C++ offersthe do-while loop:
The statement in a do-while loop always executes at least once. After the
statement has been executed, the do-while loop checks the condition. If the
condition is true, the CPU jumps back to the top of the do-while loop and
executes it again.Here is an example of using a do-while loop to display a menu
to the user and wait for theuser to make a valid choice:
F. Jump / Loop
Output :
G. If / Else
If the boolean expression evaluates true, then the if block of code will be
executed,otherwise else block of code will be executed.
When the above code is compiled and executed, it produces the following result: