0% found this document useful (0 votes)
53 views113 pages

While Loop, Do While Loop

The document discusses C++ programming and loops. It contains lecture slides on while loops, do-while loops, and for loops. It provides examples of their syntax and uses, as well as sample problems to solve using loops. Quizzes are also included that test understanding of loop syntax in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views113 pages

While Loop, Do While Loop

The document discusses C++ programming and loops. It contains lecture slides on while loops, do-while loops, and for loops. It provides examples of their syntax and uses, as well as sample problems to solve using loops. Quizzes are also included that test understanding of loop syntax in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 113

C++ Language

C++ ‫ﻟﻐـــــــــــﺔ‬
Dr. khaled Alwesabi

1 C++ Programing
Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

How many times should a data type be mentioned for a variable?

a. When entering variable’s value using cin

b. Every where the variable is used

c. when printing a variable’s value

d. Only once : when declaring the variable

2 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Lecture 5
while loop , do while loop

3 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

4 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

The condition being tested


may be relational, logical or
even numeric expression :
while (i <=10)
while (i >= 10 && i <= 15 )
while (3)
while (3+5)

5 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

6 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

7 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

8 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

9 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

10 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

The while loop:-


Exercise :
1-Write a C program that computes and print sum of numbers :
4.0, 4.5, 5.0, 5.5,…….. 9.5, 10 Use while loop.

2- Write a C++ program that computes the sum of consecutive


integer numbers 1+2+3+…….+n.
3- Write a C program that computes and print factorial for to
numbers :
( 1-10 ) where factorial of n! compute as follows : n! = n(n-
1)(n-2)…3.2.1 Use while loop.

11 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

The condition being tested may be


relational, logical or even numeric
expression :
While (i <=10)
While (i >= 10 && i <= 15 )
While (3)
While (3+5)

12 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

13 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

14 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

(a) Using a while statement


(b) Using a do while for statement
(c) Using a for statement

15 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
3- The For Loop.
 For Loop is probably the most popular looping instruction.

 General form of for statement is


for ( initialize counter ; test counter ; increment counter)
{
do this ;
and this ;
and this ;
}
The for allows us to specify three things about a loop in a single line
(a) Setting a loop counter to an initial value
(b) testing loop counter to detect whether its value reached the number of
repetitions desired.
(c) increasing the value of loop counter each time the program segment within the
loop has been executed.

16 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

17 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

18 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

19 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

20 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

21 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

22 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

23 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

24 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

25 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

26 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

27 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

28 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

29 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop

30 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement

These statements doesn't check any condition to execute the code. These

statements are pretty much useful to transfer the control from one block

to another block over the program. They are:

31 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
Break statement
The break statement is used to com out of the loop in a program.

32 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
Break statement
The break statement is used to com out of the loop in a program.

33 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
Break statement
The break statement is used to com out of the loop in a program.

34 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
continue statement
The continue statement is used to go back to the beginning of the loop
In a program.

35 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
continue statement

36 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
continue statement

37 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
goto statement
The goto statement is used to transfer the control of the program from
Any location to any location.

38 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
goto statement
.

39 ‫ﻋﻣﻠﻲ‬
Lecture 5
while loop , do while loop
Unconitional Branching statement
goto statement
.

40 ‫ﻋﻣﻠﻲ‬
Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which is the right syntax for the while loop?

a. while (bacon <= 5) { cout << “text”};

b. while bacon < = 5 cout << “text”;

c. WHILE bacon <= 5 { cout << “text”;}

d. while (test)….. do;

41 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪42‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪43‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪44‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪45‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which is the correct syntax for do ….. while loop?

a. do { } while (test);

b. Do while test;

c. Doo while(test)

d. while (test)….. do;

46 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Fill in the blanks to print x variable’s values 10 times.

int x = 0;
do{
cout << x<< endl;
x++;
}
while ( x < 10 );

47 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

How is a do … while loop different from a while loop?

a. Do… while loop runs your code at least one time

b. while loop runs the code before testing the condition

c. Do… while loop tests the condition before running the code

d. while (test)….. do;

48 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Fill in the blanks to print “ this is a loop” to the screen 15 time.

int x = 1;
do{
cout << “ this is a loop “<< endl;
x++;
}
while ( x <= 15 );

49 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which one is the correct syntax for the ‘ for ’ loop?

a. For int x = 1; y < 10 ; ++y { }

b. FOR x = 1, x < 10 , x++ { }

c. for ( int x = 1 ,, x < 10 ; x++;) { }

d. for ( int x = 1 ; x < 10 ; x ++) { }

50 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪51‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪52‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which choice shows the correct syntax for the switch


statement?

a. switch (test) { }

b. SWITCH test { }

c. Switch test ;

53 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪54‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

what would occur if we forget to insert ‘ break ‘ after a ‘


case ‘ ?

a. Nothing

b. A compile-time error

c. The rest of the cases would be executed, until

encountering break statement

55 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪56‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬
‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪57‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

the result of the ‘ a && b ‘ is true if :

a. Either a or b is true

b. Both a and b are true

c. Both a and b are false

58 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

How many && operators can be used in one if statement?

a. Only one

b. Two

c. As many as you want

59 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪60‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

The result of a || b is true if ( select two answers ) : (select all that apply)

a. Both a and b are true

b. Either a or b is true

c. Neither a nor b is true

61 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪62‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪63‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪64‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

which of the following is true for the switch statement ?

a. The switch statement is the same as the for loop

b. The switch statement must always contain a default case

c. The switch statement may be an alternative for multiple if

statements

65 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Select the correct statements about && and || operators. (select all that apply)

a. a && b is true if either a or b is true

b. a && b is false if both a and b are true

c. a || b is true if either a or b is true

d. ( a || b) && c is true if c is true and either a or b is true

66 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪67‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪68‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which of the following is a correct statement? (select all that apply)

a. delete uninstalls the program from your computer

b. Delete de-allocates memory on the heap

c. New returns a floating –point number

d. New allocates space dynamically on the heap

69 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪70‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which of the following are legal variable names in C++ ? (select all that apply)

a. 13legal_name

b. Think_is_LEGAL

c. *!@is -legal

d. notLegal

71 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪72‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪73‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

WHAT IS THE FUNCTION OF THE NEW INT; EXPRESSION?

a. Deletes all memory on the heap

b. Allocates memory on the heap

c. Declares a function named new int

d. New allocates space dynamically on the heap

74 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪75‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪76‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Every C++ program starts with the function:

a. my_function

b. main

c. #include

d. Int()

77 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪78‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

A C++ function consists of :

a. A name without any body

b. Only return type

c. Return type, function name, parameters, and a body

d. Int()

79 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪80‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

A function must be declared :

a. After it is call

b. Before its call

c. With call

d. Through of call

81 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪82‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Every C++ program starts with the functuin:

a. My_function

b. #include

c. int()

d. main

83 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪84‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪85‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

What is the factorial of 5 ?:

a. 5! Equals 5*4*3*2*1

b. 5! Equals 0

c. 5! Equals 5

d. 5! Equals 5*4*3*1

86 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪87‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

A real recursive function should have:

a. A base case

b. An empty body

c. A return value

d. Cassese real

88 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪89‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪90‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

What are the two different ways to pass arguments into functions:

a. Pass by value and pass by name

b. Pass by reference and pass by name

c. Pass by reference and pass by value

d. Only pass by values

91 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Pass by value means:

a. Pass the copy of the variable as the argument

b. Pass the address of the variable as the argument

c. Pass the main function as the argument

d. Only pass by values

92 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪93‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

A function taking an argument by reference :

a. Is a recursive function

b. Receives just a copy of the actual argument

c. Can modify the actual variable passed to it

d. Only pass actual

94 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪95‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪96‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

What is a pointer?

a. A function

b. A data type that contains an address

c. A header file

d. Variable in function

97 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪98‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪99‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪100‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which of the following expressions are legal in C++?

a. “hello” +11

b. 12 + 4

c. 12 + “Mike”

d. “hello” * 3.14

101 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which of the following are correct values for the numeric data types? (Select all
that apply)

a. “hello”

b. 3.14

c. ‘abc’

d. 1000

102 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which one is a legal character, not a string?

a. “this”

b. “or this”

c. ‘t’

d. ‘this’

103 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪104‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Is 3.14 an integer?

a. Yes

b. No

105 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪106‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫‪Quiz 2021‬‬ ‫‪Quiz‬‬ ‫‪C++ Programing‬‬

‫‪C++ Programing‬‬
‫‪Assignment 7‬‬

‫‪107‬‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Can floating point types hold negative numbers?

a. Yes

b. No

108 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

Which is a correct rule for naming a variable?

a. Cannot contain underscores

b. Cannot start with a letter

c. Cannot start with a number

109 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

What is the purpose of cin?

a. Includes a header file

b. Print variable’s value

c. Take information (data) from the user

110 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

What is the alternative for x = x + 10 ?

a. X += 10 ;

b. X = y + 10 ;

c. X -= 9 ;

d. X *= 10 ;

111 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


Quiz 2021 Quiz C++ Programing

C++ Programing
Assignment 7

X++ has the same meaning as :

a. X =x+1;

b. X /= 17;

c. X = x-4;

d. X *= 10 ;

112 (‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب واﻟﺗﺄھﯾل )أﺛﻧﺎء اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ‬


‫‪C++ Language‬‬
‫ﻟﻐـــــــــــﺔ ‪C++‬‬
‫‪Dr. khaled Alwesabi‬‬

‫‪113‬‬ ‫‪ C++‬اﻟﺧدﻣﺔ اﻟﺷوﻛﺎﻧﻲ(‬


‫واﻟﺗﺄھﯾل )أﺛﻧﺎء‬ ‫اﻟﻣﻌﮭد اﻟﻌﺎﻟﻲ ﻟﻠﺗدرﯾب‬
‫‪Programing‬‬

You might also like