/Conditions , C

Conditions , C

Today I’m going to talk about the conditions and loops in C and how it is implemented.

First , let’s talk about conditions
As an example : I’ll pass the exams IF i study , so there’s a condition for passing the exam which is studying…
just like the previous example , the conditions do like this
” if something happens , do other thing “
let’s see it with a code

this code takes a number from the user and prints it IF it equals zero , if it’s not then the program ends without printing anything.
there’s also “else if” which handles more than two conditions like the following :

NOTE: I can replace the last “else if” with “else” without affecting the logic of the program , also i can make it with one if statement and one else statement without else if , try it out 😉
we can combine two or more conditions logically with && (AND) , || (OR)
&& (AND) : the conditions must be true.
|| (OR) : one of the conditions should be true.
also the ! sign refers to not , but the opposite of the conditions  like if (!true) means false and vise versa
also , we can handle some conditions with switch statement , which i told it if the input case X , execute some statements as follows

NOTE : you should type a break statement so as not to execute the other cases …
finally , with goto
it’s used when you want to go back to a point in the code , usually used when the user entered an invalid data
here’s an example of using it

and Now , show me after this article how to make a simple calculator that adds , subtracts , multiplies and subtracts two numbers “the answer will be in the next article inshalla”