0% found this document useful (0 votes)
3 views1 page

Understanding If Statements in Programming

The document explains the use of if statements in programming, which allow actions to be taken based on whether a condition is true or false. It provides a basic structure for an if statement and presents a coding exercise to create a function that displays the sum of two numbers if the first is less than or equal to the second, otherwise it displays their difference. The document is associated with CLUB ROBOTIQUE in Kairouan, represented by Hamza Belgarouia.

Uploaded by

Hamza Belgarouia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Understanding If Statements in Programming

The document explains the use of if statements in programming, which allow actions to be taken based on whether a condition is true or false. It provides a basic structure for an if statement and presents a coding exercise to create a function that displays the sum of two numbers if the first is less than or equal to the second, otherwise it displays their difference. The document is associated with CLUB ROBOTIQUE in Kairouan, represented by Hamza Belgarouia.

Uploaded by

Hamza Belgarouia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

If Statement (Conditional Statement)

Use an if statement to change the output conditions based on changing


the input conditions.

The if() statement is the most basic of all programming control structures. It allows
you to make something happen or not, depending on whether a given condition is
true or not. It looks like this:
if (someCondition) {
// do stuff if the condition is true
} else {
// do stuff if the condition is false
}
It’s your turn!
Try now to write the code for our “Function do_calc” : if nbre1 is less or equal to
nbre2 then display the result of their sum a+b if not display the result of the following
operation: a-b :

CLUB ROBOTIQUE
Kairouan Centre-Ville ( Gargabiya)
Hamza Belgarouia
54405750

You might also like