Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Cedrick Vincent A.

Tapalla

BSCE 1A

Assignment in CFP

1.what is IF statement in C++

:IF statement in C++ is used when making a conditional codes

Or coditional statement. If the condition

Is true the block of code will be exicuted and if the condition


Is false, the code within the block is skipped.

2.What hand IF…. ELSE statement

:The “if…else” statement in C++

Allows you to execute different blocks of code depending on

Whether a specified condition is true or false. Here’s how it

Works:

The “if” statement starts with evaluating

A condition inside parentheses. This condition can be any

Expression that results in true or false.


If the condition evaluates to true,

The block of code immediately following the “if” statement

(enclosed within curly braces {}) is executed. This block of

Code is known as the “if block”.


If the condition evaluates to false,

The block of code immediately following the “else” keyword

Is executed.

This block of code is known as the “else block”.


3.What is NESTED IF in C++

:Nested “if” statements in C++ refer to the practice of

Placing one “if” statement inside another. This allows for

More complex conditional logic where conditions are evaluated

Hierarchically.

4.What is SWITCH STATEMENT in C++


:A switch statement in C++ is a control flow statement that

Allows a program to evaluate an expression and then execute

Different branches of code based on the value of that

Expression. It provides an alternative way to write multiple

If…else if…else statements when the conditions are based

On the value of a single variable.

5.Repetition Structure

:Repetition structures in C++ are used to execute a block of

Code repeatedly based on certain conditions

a. While

The while loop repeatedly executes a block of code as


Long as a specified condition is true.

b. Do While

The do-while loop is similar to the while loop, but it always


Executes the code block at least once, and then checks the condition.

c. For Loop

The for loop is used when you know the number of iterations
In advance. It combines the initialization, condition check,

And iteration update into a single line.

d. Using Break and Continue within Loop

Break: It is used to exit the loop immediately,

Regardless of the loop’s condition.

Continue: It is used to skip the rest of the code inside

The loop for the current iteration and proceed to the


Next iteration.

You might also like