IF, IF - Else, IF - Else If Statements
IF, IF - Else, IF - Else If Statements
C++ ﻟﻐـــــــــــﺔ
Dr. khaled Alwesabi
1 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to declare variable a of type int and then assign 7as its value ?
____ a;
a_____7
bool
2 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
3 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
4 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Type in a code to declare variable b and assign a’s value to b, and then print their
sum to the screen :
5 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Type in the code that allows for entering a number and strong it in the variable a:
C++ Programing
Assignment 7
Fill in the blanks to declare a variable var of type int , enter a value, and store it in
the variable var :
7 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Type in a code to declare variable b and assign a’s value to b, and then print their
sum to the screen :
8 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the missing parts of the code to declare sum as a variable, assign it the value
21 + 7, and print out its value :
9 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
10 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. +
b. %
c. *
d. x
11 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to declare variable x and assign it the value 81 divided by 3:
12 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. *
b. +
c. %
d. &
13 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
14 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
15 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
16 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. X = x + 1;
b. X / = 17;
c. X = x – 4;
d. X *= 1
17 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to increment x’s value by one using the ++ oprator and print its
value to the screen:
18 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
What’s the difference between ++x and x++? Select all that apply
19 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Please type in a code that decrements x’s value using the – operator.
20 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Please fill in the missing parts of the code to print “I love C++” on the screen.
21 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Please type in a code that declares two variable of type int and parts their sum to
the screen.
22 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
In every C++ program : (Select all that apply)
23 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
What is the output of the following code?
24 C++ Programing
Lecture 4
IF , IF - Else , IF - Else If statements
3. Nested if statements
Yes
If (condition)
{
Statement 1;
Statement 2;
.
.
.
Statement n;
}
if ( x > y )
false
if ( x > y )
true
C++ Programing
Assignment 7
Which choice shows the correct syntax for the if statement in C++ ?
a. if ( test) { }
b. If test
c. If test
d. if { } ( test )
35 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to compare the variables and print “ hi there “ to the screen:
36 C++ Programing
Lecture 4
IF , IF - Else , IF - Else If statements
C++ Programing
Assignment 7
38 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. =
b. ==
c. *=
d. <<
39 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to compare the variables and print “ not equal “ to the screen:
40 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
41 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
42 C++ Programing
Lecture 4
IF , IF - Else , IF - Else If statements
float x,y ;
cout<< "Enter the values x ";
cin>> x ;
y = ( x>= 0 )? 5-x*x : 2*x*x*x;
cout <<"The value Y = “ << y;
return 0;
C++ Programing
Assignment 7
59 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the blanks to compare the variables and print the “ printing in the else “ text
to the screen :
60 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. 2
b. 1
61 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
a. Only two
c. None
62 C++ Programing
Quiz 2021 Quiz C++ Programing
C++ Programing
Assignment 7
Fill in the missing parts of the nested if statements to print “it works !” to the screen
63 C++ Programing
C++ Language
C++ ﻟﻐـــــــــــﺔ
Dr. khaled Alwesabi
64 C++ Programing