if statement in c code example
Example 1: c if else
if (<condition>) {
<code>
} else if (<condition>) {
<code>
} else {
<code>
}
int money = 50;
if (money < 15) {
go_home();
} else if (money >= 600) {
buy_all();
} else {
buy_tickets(money / 15);
}
Example 2: syntax of if stmt
if (condition)
{
}
Example 3: if statement in c
#include <studio.h>
int main()
{
if (logic goes here)
{
CODE
}
else if (logic)
{
CODE
}
else{
CODE
}
return 0
}
Example 4: c check if char is an operator
char o = '+';
if (o == '%' || o == '/' || o == '*' || o == '+' || o == '-') {
}
Example 5: c#if
if(number > 10)
Console.WriteLine("test1");
else
if(number < 0)
Console.WriteLine("test2");