SITE SCIENTIFIQUE D'AZROU

Informatique - Computer science

C/C++

Lesson four 4.


In this lesson we will learn about condition instructions:

If (condition1) {instruction 1 ;}
Else if (cond2) {instruction 2;}
.
.
.
Else if (cond n-1) {instruction n-1;}
Else (cond n) {instruction n;}

This function allow us to run instruction 1 if the first condition is true, if not, the computer Will try the second condition and run the instruction2 if it's true, if not, it goes To the next and so on till the n instruction.
Now we'll write an algorithm on how to resolve a 2nd degree equation, Then we'll translate it to a C language.

Algorithm :


To use conditions into your code, you must have some knowledge on logic:
Lets A, B, (A and B), (A or B), (A xor B) and (not A) 6 sentences, T : true ; F :false

The (And) :
and A , B and (A et B) are three sentences
A B A et B
T T T
T F F
F T F
F F F
equivalence :
A B A eqv B
T T T
T F F
F T F
F F T
The (Not):
Lets A be a sentence proposition, T : true ; F :false
A not A
T F
F T
The (Xor):
A B A xor B
T T F
T F T
F T T
F F F
The (Or):
A B A or B
T T T
T F T
F T T
F F F

http://Azrousoft.8m.com