How to Make Decision / Branch in C / C++



     In making the decisions, we have to specify the conditions to be evalueted by the program. The statement are executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.


This is the flow diagram of decision making !


























There are many ways to make decision, those are :


  - If statement

An if statement consists of a boolean expression followed by one or more statements.

Example ; 





  - If .... Else Statement


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

Example : 



 - Switch Statement

switch statement allows a variable to be tested for equality against a list of values.

Example :


0 komentar:

Posting Komentar

Diberdayakan oleh Blogger.

Text Widget

Popular Posts

Recent Posts

Copyright © 2025/ Learn About C / C++

Template by : Urangkurai / powered by :blogger