Skip to content

Commit 2e40305

Browse files
committed
Add Conditions and Branches in C++
1 parent 2596a86 commit 2e40305

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

HelloWorld/Main.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@
33

44
int main()
55
{
6-
int a = 8;
7-
a++;
8-
const char* string = "Hello";
6+
int x = 5;
97

10-
for (int i = 0; i < 5; i++)
11-
{
12-
const char c = string[i];
13-
std::cout << c << std::endl;
14-
}
8+
if (x == 5)
9+
Log("Hello World!");
10+
11+
if (x)
12+
Log("Hello World!");
13+
14+
const char* ptr = "Hello";
15+
if (ptr)
16+
Log("Hello World!");
17+
18+
ptr = nullptr;
19+
if (ptr)
20+
Log(ptr);
21+
else if (ptr == "Hello")
22+
Log("Ptr is Hello!");
23+
else
24+
Log("Ptr is null!");
1525

16-
Log("Hello World!");
1726
std::cin.get();
1827
}

0 commit comments

Comments
 (0)