C++ Program to swap two numbers without third variable8 Mar 2025 | 1 min read We can swap two numbers without using third variable. There are two common ways to swap two numbers without using third variable:
Program 1: Using * and /Let's see a simple C++ example to swap two numbers without using third variable. ExampleCompile and RunOutput: Before swap a= 5 b= 10 After swap a= 10 b= 5 Program 2: Using + and -Let's see another example to swap two numbers using + and -. ExampleCompile and RunOutput: Before swap a= 5 b= 10 After swap a= 10 b= 5 Next TopicMatrix multiplication in C++ |
An accumulator is a register in a computer's central processing unit (CPU) that stores intermediate results of arithmetic and logic operations. It is an essential component of many programming languages and has been used in various forms since the early days of computing. In this...
3 min read
In this article, you will learn about how to get the value of Pi in C++ with several methods. A few of the mathematical functions in C++ are used to determine Pi(π). 1. Making Use of Pre-Defined Constants The M_PI constant is available in C and C++ and...
4 min read
Pattern recognition is an important problem in the field of computer science. Pattern searching methods display the search results when we search for a string in a notepad/word document, browser, or database. The following is an example of a problem statement: Given a string text[0..n-1] and a...
4 min read
The binding which can be resolved by the compiler using runtime is known as static binding. For example, all the final, static, and private methods are bound at run time. All the overloaded methods are binded using static binding. The concept of dynamic binding removed the problems...
3 min read
To faithfully explain the concept of . We first discussed the List in C++n programming language's code and output below. The forward list c before begin function is an in-built functionality in STL [Standard Template Library (STL)]. It returns a constant random-access iterator which points to...
3 min read
C++ Generic Programming Introduction Using C++ templates, the generic programming pattern generalizes the approach so that it may be used with a variety of data types. Instead of specifying the actual data type, we supply a placeholder in templates, and that placeholder is substituted by the data...
7 min read
Effective data type handling is critical when working with C and C++ programs. The conversion of strings to double-precision floating-point values is an often encountered scenario that can be handled using the strtod() function. Despite its seeming simplicity, this function has several complexities and factors that...
3 min read
In this article, you will learn about why global variables are evil in C++: Outside of any program function, global variables are defined and declared. For the duration of the program, they uphold their ideals. Throughout the program's execution, they are available. Global variables that are not const...
3 min read
The Edmonds-Karp algorithm is a powerful and efficient method for finding the maximum flow in a flow network, which is a directed graph where each edge has a capacity representing the maximum amount of flow it can carry. The algorithm builds upon the Ford-Fulkerson method but...
11 min read
Strtok in C is comparable to this function. Tokens are created from the input sequence and are separated by separators. Through the predicate, separators are provided. Syntax: Template: split(Result, Input, Predicate Pred); Parameters: Input: A container which will be searched. Pred: A predicate to identify separators. This predicate is supposed to return...
4 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India