The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
All programming languages enable you to make decisions. They enable the program to follow a certain course of action depending on whether a particular condition is met. This is what gives programming language their intelligence.
if(condition) { here goes statements; . . . . here goes statements; }
if statements are commonly used in following scenarios
Arduino microcontroller make use C programming, where you need to blink a warning light(red light) when certain condition met. Example program is as below:
if(x = 123) digitalWrite(LEDpin, high)
x is a variable which get its input from a sensor continuously.
Following flow chart will clearly explain how if statement works
#include <stdio.h> //header file section #include <conio.h> int main() { int age = 18; if(age > 17){ printf("you are eligible for voting "); } printf("\nThis is normal flow "); return 0; }
If the user input is greater than 17, then the condition will be true and the statements under if condition gets executed. Otherwise, it executes next to the if block.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019