Hi
I am having difficulty to remember the use of statement (if else ) and loop (for, while ) in c programming. I don't understand when I need to use statement (if else ) and loop (for, while ).
if else : if switch is ON , LED should be ON
else LED should be off
so I think if there is only two condition true and false than I have to use If else conditions.
while loop : check the condition. if condition is true than do true things and things will repeat all time like if the switch is ON , blink LED for every 2 seconds
For loop: if the switch is ON than blink LED only for 2 second
so I am struggling with basic. how to remember permanently to the use of statement and loop in c programming ?
I am having difficulty to remember the use of statement (if else ) and loop (for, while ) in c programming. I don't understand when I need to use statement (if else ) and loop (for, while ).
if else : if switch is ON , LED should be ON
else LED should be off
Code:
if (condition )
{
/* if the condition is true, switch is ON, than LED will ON*/
}
else {
/* if the condition is false, switch is OFF than LED will OFF */
}
while loop : check the condition. if condition is true than do true things and things will repeat all time like if the switch is ON , blink LED for every 2 seconds
Code:
while (condition)
{
statements;
}
so I am struggling with basic. how to remember permanently to the use of statement and loop in c programming ?