Conditional Statements in C++ Programming Flashcards

1
Q

[ Identification ]

It evaluates TRUE or FALSE statement.

A

Boolean Expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

[ Identification ]

  • Developed by George Boole.
  • A branch of discrete mathematics that is dedicated to the study of the properties and the manipulation of logical expressions.
  • Uses relational operators to compare expressions.
A

Boolean Algebra

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

[ Identification ]

He developed Boolean Algebra.

A

George Boole

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

[ Identification ]

Used to compare the value of two variables.

A

Relational Operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

[ Identify / illustrate the operator being described. ]

Used when the value of two variables are equal.

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

[ Identify / illustrate the operator being described. ]

Used when the value of two variables are not equal.

A

!=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

[ Identify / illustrate the operator being described. ]

Used when one value is greater than another.

A

>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

[ Identify / illustrate the operator being described. ]

Used when one value is greater than or equal to another.

A

> =

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

[ Identify / illustrate the operator being described. ]

Used when one value is less than another.

A

<

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

[ Identify / illustrate the operator being described. ]

Used when one value is less than or equal to another.

A

<=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

[ Identification ]

  • Also known as selection statements
  • Used to make decisions based on a given condition.
A

Conditional Statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

[ True or False ]

If the condition evaluates to TRUE, a set of statements is executed, otherwise another set of statements is executed.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Conditional statements are also known as _______ ________.

A

selection statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

[ What are these? ]

  • Simple IF Statement
  • IF - ELSE Statement
  • NESTED IF Statement
  • SWITCH Statement
A

Forms of Conditional Statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

[ Identification: Forms of Conditional Statement ]

  • A powerful statement for decision making and is used to control the flow of execution of statements.
  • A two-way decision-making statement and is used in conjunction with an expression.
A

Simple IF Statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

[ Identification: Forms of Conditional Statement ]

STRUCTURE:
if(condition)
{ statement; }

Example:
if(x==100)
{
cout«“x is 100”;
}

A

Simple IF Statement

17
Q

[ Fill in the blanks. ]

An __ ______ can be followed by an optional ____ _______, which executes when the Boolean expression is false.

A

An if statement can be followed by an optional else statement, which executed when the Boolean expression is false.

18
Q

[ True or False ]

If the Boolean expression evaluates to true, then the else block will be executed, otherwise, the if block will be executed.

A

False.

If the Boolean expression evaluates to true, then the if block will be executed, otherwise, the else block will be executed.

19
Q

[ Identification: Forms of Conditional Statement ]

  • An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.
A

IF - ELSE Statement

20
Q

[ Identification: Forms of Conditional Statement ]

STRUCTURE:
if(condition)
{
statement 1;
}
else
{
statement 2;
}

Example:
if(Grade>=75)
{
cout«“Congratulations, You Passed!”;
}
else
{
cout«“You failed, better luck next time!”;
}

A

IF - ELSE Statement

21
Q

[ Identification: Forms of Conditional Statement ]

  • Use one if or else if statement inside another if or else if statement(s).
A

NESTED IF - ELSE Statement

22
Q

[ Identification: Forms of Conditional Statement ]

STRUCTURE:
if(condition)
{
if(condition 1)
{ statement 1; }
else
{ statement 2; }
}
else
{ statement 3; }

Example:
int ctr = 0;
int Password;
if(Password==”JRUat100”)
{
cout«“Login Succesfully!};
}
else
{
cout«“Login Failed!”;
ctr++;
if (ctr==3){
cout«“Pease Try again later!”; }
}

A

NESTED IF - ELSE Statement

23
Q

[ Identification: Forms of Conditional Statement ]

  • Allows a variable to be tested for equality against a list of values.
  • Used when you have multiple possibilities for the if statement.
A

SWITCH Statement

24
Q

[ Identification: Forms of Conditional Statement ]

STRUCTURE:
switch(variable)
{
case 1:
//execute your code
break;

case n:
//execute your code
break;

default:
//execute your code
}

Example:
int num = 2;
cout«“Pls enter number”;
cin»num;
switch(num) {

case 1:
cout«“You selected 1.”;
break;
case 2:
cout«“You selected 2.”;
break;
default:
cout«“Pls select a number from 1-2”;
}

A

SWITCH / SWITCH CASE Statement

25
Q

[ Fill in the blanks: Rules in Switch Statement ]

The expression used in a switch statement must have an ______ or enumerated type or a class type in which the class has a single conversion function to an ______ or enumerated type.

A

integral

26
Q

[ Fill in the blanks: Rules in Switch Statement ]

You can have any number of _____ ______ within a switch. Each case is followed by the value to be compared to and a colon.

A

case statements

27
Q

[ Fill in the blanks: Rules in Switch Statement ]

When a _____ statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.

A

break

28
Q

[ Fill in the blanks: Rules in Switch Statement ]

A switch statement can have an optional ______ case, which must appear at the end of the switch. The _____ case can be used for performing a task when none of the cases is true. No _____ is needed in the ____ case.

A

A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.

29
Q

[ Identification ]

Used to perform logical operations on the given two variables.

A

Logical Operators

30
Q

[ Identify / illustrate the operator being described. ]

Executes TRUE statement if all conditions are TRUE.

A

&& - AND

31
Q

[ Identify / illustrate the operator being described. ]

Executes TRUE statement if either of the conditions is TRUE.

A

|| - OR

32
Q

[ Identify / illustrate the operator being described. ]

Executes TRUE statement if the condition is FALSE.

Executes FALSE statement if the condition is TRUE.

A

! - NOT