Learn C++ with me part 1-4

download.png

Part1

let's try simple coding and printout "Hello World" in C++

try this code to printout "Hello World in C++

#include
int main(void) {

std::cout<<"Hello World";

return 0;

}

Capture.PNG

Syntax: std::cout

The std::cout statement in C++ is a built-in output function that allows the computer to display a
certain text or number on the screen. When printing strings (or text), the syntax is as follows:

std::cout << “Hello World”;

A pair of double quotes (") surround the text to be outputted, and the entire line of code finishes with a semicolon (;).
We can't use the std::cout function right away since we don't have the header file we need to utilize these standard input/output methods. To do so, we'll need to use the built-in library!

Part 2

Now let try the basic escape in C++

Escape sequences are special characters characterized by a backslash () and a letter or symbol beside it. It is used in std::cout statements to show spaces, new lines, or show symbols that cannot be outputted using the normal way of printing.

There are a lot of escape sequences available in C++, but we will only be tackling the most basic ones.

try this code

#include

int main(void) {

std::cout<<"G\n\nO\n\nG\n\nO";

return 0;

}

Capture1.PNG

Part 3

Basic math
Just like your elementary mathematics, C++ also has a similar set of math operations, with an addition of some other set of symbols for specified purposes.

try this code

#include

#include

int main(void) {

int a = -8 ;
int b = -2;
int total = a + b;
std::cout<<"-8+-2="<<total;


return 0;

}

Capture2.PNG

part 4

Now let’s start with something simple! Make a program that accepts a single character and an integer and print it out afterward.

#include

#include

int main(void) {

int a = 4 ;

std::cout<<"C ";
std::cout<< a;

return 0;

}

3.PNG

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now