C++ Program to Add Two Numbers

sudhir sharma
Updated on 09-May-2025 15:26:44

14K+ Views

In this article, we'll show how to add two numbers using C++ and display the result. Adding two numbers is a basic arithmetic operation, meaning we combine their values to get a total. We will see different methods to solve this. Different Ways to Add Two Numbers in C++ In C++, there are various approaches to add two numbers, each approach using its own cases and advantages. Below are the mentioned list: Using Addition Operator Using User Input Using Increment and Decrement Operators ... Read More

Eliminate Repeated Lines in a Python Function

Sarika Singh
Updated on 09-May-2025 15:25:12

6K+ Views

In this article, we will discuss how to delete multiple lines that are repeated in a Python Function. If the file containing the program is small and only has a few lines, we can remove repeated lines manually. However, when dealing with huge files, we need a Python program to do so. Using the File Handling Methods Python has built-in methods for creating, opening, and closing files, which makes handling files easier. Using the methods, we can also perform several file actions, such as reading, writing, and appending data (while files are open). To remove duplicate lines from a text ... Read More

C++ Program to Reverse a Number

Nishu Kumari
Updated on 09-May-2025 15:18:28

2K+ Views

In this article, we will show you how to reverse a number using C++. Reversing a number means changing the order of its digits, so the first digit moves to the end, the last digit moves to the front, and the middle digits follow in the opposite order. For example, if we start with the number 1234, the reversed number will be 4321. In C++, we can reverse a number in different ways. Some common approaches we can use are: Using a Loop Using Recursion ... Read More

Calculate Power of a Number in C++

Nishu Kumari
Updated on 09-May-2025 15:17:36

6K+ Views

In this article, we'll show you how to calculate the power of a number in C++. Calculating a power means multiplying the base by itself as many times as the exponent indicates. For example, 2 raised to the power of 3 (2^3) means multiplying 2 by itself three times: 2 * 2 * 2, which gives 8. In C++, there are different ways to calculate the power of a number. Below are the approaches we cover: Using a Loop Using Recursion Using the pow() Function ... Read More

Check Whether a Character is Vowel or Consonant in C++

Nishu Kumari
Updated on 09-May-2025 15:16:30

12K+ Views

In this article, we'll show you how to write a C++ program to check if a given character is a vowel or a consonant. Vowels are the letters 'a', 'e', 'i', 'o', 'u'(both uppercase and lowercase), and all other alphabetic characters are consonants. For example, if we input the character 'a', the program will output 'vowel'. If we input 'b', it will output 'consonant'. In C++, there are different ways to check if a character is a vowel or consonant. Below are the common methods: Using an if-else statement ... Read More

Find Patterns of 10plus1 in a String Using Python Regex

Sumana Challa
Updated on 09-May-2025 12:17:34

268 Views

The term "10plus1" is a specific pattern in a binary string that starts with a digit '1' followed by at least one or more '0' and ending with a '1'. In regular expressions this pattern is represented as - 10+ 1 Using re.findall() The re.findall() method accepts a pattern and a string as parameters, finds the given pattern in the entire string, and returns all the matches in the form of a list.To find the patterns of "10+1" in a given string, we just need to pass the same as pattern to the findall() method along with the string.Example ... Read More

C++ Pointers vs Java References

Nishu Kumari
Updated on 09-May-2025 11:34:00

2K+ Views

In this article, we will show you the difference between C/C++ pointers and Java references. C/C++ use pointers to manually control how memory is used and accessed. Java, on the other hand, does not support pointers and uses references instead, which manage memory automatically. Pointer in C/C++ A pointer is a variable that holds the address of another variable in memory. It gives you direct access to that memory, which is powerful but can lead to errors if not used carefully. Syntax Here's the syntax where we declare a pointer with an asterisk(*) ... Read More

Find Largest Element of an Array in C++

Nishu Kumari
Updated on 09-May-2025 11:31:59

8K+ Views

In this article, we'll show you how to write a C++ program to find the largest element in an array. An array is a collection of values that share the same data type. Our task is to go through all the elements stored in the array and find the one with the highest value. For example, consider the following arrays: //Example 1 int arr[] = {11, 13, 21, 45, 8}; Here, the largest element is 45. //Example 2 int arr[] = {1, 9, 2, 5, 7}; In this case, the largest element is ... Read More

Bitwise XOR of Hex Numbers in Python

Sumana Challa
Updated on 09-May-2025 10:44:12

4K+ Views

The bitwise XOR is a binary operation in which we compare two binary numbers bit by bit and return the value "1" if the bits are not same, and 0 if they are the same. The XOR(exclusive OR) operation follows the below rules - A B A ⊕ B ... Read More

Remove Same Element from List in Python

Sumana Challa
Updated on 09-May-2025 10:30:40

3K+ Views

A list is a built-in Python data structure that is used to store an ordered collection of items of different data types. It often occurs that lists contain duplicate values, i.e., the same element repeating multiple times, which causes data inaccuracies. In this article, we will discuss the approaches that can be used to remove the repeated elements from a list. Using set() Using List Comprehension Using a For Loop Using Dictionary fromkeys() Using set() Function The set() function accepts an iterable ... Read More

Advertisements