-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCondition.cpp
More file actions
46 lines (39 loc) · 749 Bytes
/
Condition.cpp
File metadata and controls
46 lines (39 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
int main(){
/* IF */
// IF simples (Apenas exemplo)
if(true){ /* Condição booleana */
// Se a condição for verdadeira.
}
else {
// Se as condições não atendidas faça.
}
// Multiplos IFs com ELSE (Apenas exemplo)
if(true){
}
else if(true){
}
else{
// Caso nenhuma condição dos IFs for verdadeira
}
// IF ternário
int v_ou_f =
1 + 1 == 2 /* Condição */
? 1 /* Caso true */
: 0 /* Caso false */
;
int number = 1;
/* SWITCH */
switch(number){
case 1:
printf("Number 1");
break;
case 2:
printf("Number 2");
break;
default:
printf("Default");
break;
}
}