Correct and incorrect variable naming conventions in C++
Sunday, June 30, 2024 in C++
Categories:
This program example demonstrates the correct and incorrect variable naming conventions in C++ /** * @file main.cpp * @brief This program demonstrates the correct and incorrect variable naming conventions in C++. */ #include <iostream> using …
The use of octal, binary and hexadecimal literals in C++
Sunday, June 30, 2024 in C++
Categories:
This function defines three integer variables, each initialized with a different type of literal (hexadecimal, octal, binary). It then prints the values of these variables to the console. /** * @file main.cpp * @author ibrahim * @date 30-06-2024 * …
C++ int variable with different defining ways
Sunday, June 30, 2024 in C++
Categories:
We are explaining the use of int variables with different defining ways // Creator: ibrahim (30.06.2024 00:00) /** * @file main.cpp * @brief Demonstrates the use of int with different defining ways in C++ */ #include <iostream> /** * @brief …
C++ Hello World with explanaition
Sunday, June 30, 2024 in C++
Categories:
We tried to explain the most simple C++ program for beginners. #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; } The provided code is a simple C++ program that prints “Hello, …
C++ Defining a Pointer and changing its value
Friday, June 28, 2024 in C++
Categories:
In this example, we define a pointer and show how to view and change its value. /** * @brief Main function that demonstrates pointer manipulation. * * This function initializes an integer variable `value` with the value 10. * It then creates a …
Factorial calculation with C++ do-while loop
Friday, June 28, 2024 in C++
Categories:
In this example, we show how to calculate factorial using the do while loop. #include <iostream> using namespace std; int calculateFactorial(int number) { int result = 1; for (int i = 1; i <= number; i++) { result *= i; } return result; } …
C++ Example calculating the factorial of the entered number
Friday, June 28, 2024 in C++
Categories:
In this example, we show how to calculate the factorial of the entered number with the help of a function. #include <iostream> using namespace std; int factorial(int num) { int result = 1; for (int i = 2; i <= num; i++) { result *= i; } …
C++ adding int and float variables
Friday, June 28, 2024 in C++
Categories:
In this example, we show how to find the sum of 2 variables of type int and float. #include <iostream> int main() { int firstNumber = 11; float secondNumber = 12.8; float sum = firstNumber + secondNumber; std::cout << "Sum: " …
C++ Code example to convert Fahrenheit temperature to Celsius
Friday, June 28, 2024 in C++
Categories:
In this example, the entered Fahrenheit temperature value is converted to Celsius value with the help of a function. #include <iostream> #include <iomanip> #include <limits> float temperatureConversion(const float …
Printing int, float and string values with printf in C++
Friday, June 28, 2024 in C++
Categories:
This code defines a main function where the int and float variables are constants and the text variable is not. Prints the values number, realNumber, and text and then returns 0. #include <iostream> #include <cstdio> #include …