C++ 2 string variable concatenation
Thursday, June 27, 2024 in C++
Categories:
In this article, we show an example of combining 2 string variables. #include <iostream> #include <string> int main() { std::string firstString = "prs"; std::string secondString = "def"; std::string result; result = …
Combining 2 variables of type char in C++
Thursday, June 27, 2024 in C++
Categories:
In this example, you can see how to combine 2 char variables with a length of 50 characters using the strcat method. #include <iostream> #include <cstring> using namespace std; int main() { constexpr size_t bufferSize = 50; char …
Finding whether a number is positive or negative with C++
Thursday, June 27, 2024 in C++
Categories:
In this example, we check whether the number entered from the keyboard is positive, negative or zero by using if-else if. #include <iostream> using namespace std; int main() { int number; cout << "Please enter a number: "; cin …
C++ Nested if statement
Saturday, June 22, 2024 in C++
Categories:
In this article, we share an example showing C++ nested if statement. #include <iostream> using namespace std; int main() { /* nested if else statement */ int a; cout << "Enter a positive integer number: "; cin >> a; if (a …
C++ Cascade if else statement
Saturday, June 22, 2024 in C++
Categories:
You can see the usage of cascade if-else statement example below. #include <iostream> using namespace std; int main() { /* cascade if else statement */ int a; cout << "Enter a positive integer number: "; cin >> a; if (a < …
C++ if else statement
Saturday, June 22, 2024 in C++
Categories:
In this article, you can examine the use of C++ if else statement. #include <iostream> using namespace std; int main() { /* if else statement */ int a; cout << "Enter a positive integer number: "; cin >> a; if (a < 20) { …