C/C++ Macro for String Concatenation

Farhan Muhamed
Updated on 16-Apr-2025 19:01:53

5K+ Views

C++ provides multiple ways to concatenate strings. Macro string concatenation is one of such way. In this article, we will learn how to use C++ preprocessor macros to concatenate strings and tokens. Understanding Macros in C++ In C++, macros are small pieces of code that are defined using the preprocessor directive #define. Macros are generally used to define variables, constants, functions, and other code blocks. When the code is compiled, the preprocessor replaces every occurrence of the macro with its defined value before actual compilation begins. Let's see an example of a macro definition and its usage. // ... Read More

C++ Program to Implement Radix Sort

Ravi Ranjan
Updated on 16-Apr-2025 19:01:43

4K+ Views

The radix sort is a non-comparative sorting algorithm that sorts the individual digits of the given numbers in the list. It sorts the numbers digit by digit, starting from the least significant digit to the most significant digit. The radix sort assumes that all the input elements are k-digit numbers. So, if the elements do not have the same number of digits, find the maximum number of digits in an input element and prepend zeroes to the elements having less number of digits. In this article, we have an unsorted array of integers and our task is to implement the ... Read More

Differences Between Protected and Default Access Specifiers in Java

Shriansh Kumar
Updated on 16-Apr-2025 18:59:58

11K+ Views

The protected and default access modifiers determine how a member of a class or method can be accessed. The modifiers are attached to the members at the time of declaration. Since Java follows the object-oriented programming paradigm, these access modifiers are used in encapsulation, polymorphism, and inheritance to control the behavior of class members. We will try to understand the difference between protected and default access modifiers in Java through this article. Protected Access Modifier The protected access modifier is mostly used in the case of inheritance to control the access of parent class members and corresponding child class members. ... Read More

Differences Between JRadioButton and JCheckBox in Java

Alshifa Hasnain
Updated on 16-Apr-2025 18:55:15

3K+ Views

Both JRadioButton and JCheckBox components can extend the JToggleButton class in Java, the main difference is that JRadioButton is a group of buttons in which only one button can be selected at a time, whereas JCheckBox is a group of checkboxes in which multiple items can be selected at a time. JRadioButton A JRadioButton is a component that represents an item with a state selected or unselected. Usually, a group of radio buttons is created to provide options to the user, but only one option can be selected at a time. JRadioButton will generate an ActionListener, ChangeListener, and ItemListener interfaces.  Instantiating JRadioButton: JRadioButton Radio_Name = new JRadioButton(); ... Read More

Create a Login Form in Java

Alshifa Hasnain
Updated on 16-Apr-2025 18:54:02

33K+ Views

We can develop a login form in Java using Java Swing technology. In this example, we can create two labels username and password, two text fields for the user to enter valid credentials,  and finally, one submit button. Once the user is able to enter the valid credentials in the two text fields, we can able to see Hello admin in the login form. Setting Up the Project We’ll use Java Swing, a GUI toolkit for building desktop applications. Required Libraries are: javax.swing.* (for Swing components) java.awt.* (for layout management) ... Read More

Change Order of public static void main in Java

Alshifa Hasnain
Updated on 16-Apr-2025 18:53:41

4K+ Views

Yes, we can change the order of public static void main() to static public void main() in Java, the compiler doesn't throw any compile-time error or runtime error. In Java, we can declare access modifiers in any order, the method name comes last, the return type comes second to last and then after it's our choice. But it's recommended to put access modifier (public, private and protected) at the forefront as per Java coding standards. Java Method Modifiers and Their Order Java allows you to place method modifiers (the keyword "public, " "static, " "final, " etc.) in various orders. The Java ... Read More

Convert Hex String to Int in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:40:11

48K+ Views

A Hexadecimal is the base-16 number system that uses the digits from the '0 to 9' and letters from 'A to F'. It is commonly used in the computers to represent the binary data in the readable format. In this article we are going to learn about converting hex string into int. For example, if we receive the input as a hex string("12xf2") and need to convert it into a integer. For achieving this, Python provides the multiple methods let's explore them one by one. Using Python int() Function The Python int() function is used to convert ... Read More

Strip Punctuation from a String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:37:48

2K+ Views

When working with the text data in Python, We will come across the situations where we find the unwanted punctuation marks (like ., :?!) to remove. Removing punctuation helps to normalize text, making it easier to analyze. Python provides the several ways to achieve this, Let's dive into the article to learn ore about it. Using Python translate() Method The Python str.translate() method is a sequel for the maketrans() method in the string module. This method uses the translation table generated by the maketrans() and translate all characters based on the one-to-one mapping in the said table. ... Read More

Get Variable Name as String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:34:46

32K+ Views

In Python Variables are just the labels that are pointing to the values. They don't carry any built-in metadata about their names. That’s why there is no direct built-in method to get the variable name as a string. However, we can achieve this, by inspecting the environment such as using the globals(), locals(), or the inspect module. Let's dive into the article to learn more about getting a variable name as a string. Using Python globals() Function The Python globals() function is used to return a dictionary representing the current global symbol table. It provides ... Read More

Get Function Name as String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:28:57

18K+ Views

In Python, Functions are the first-class object, which means they can be passed around and manipulated like other data types (like integers, strings). This allows to inspect and retrieve the attribute of functions, including their names. In this article we are going to learn about getting the function names as string, To achieve we are going to use the built-in __name__ attribute. Let's dive into the article to learn more about it. Using Python Class __name__ Attribute The Python __name__ attribute is a special built-in variable that helps to determine the context in a which a Python ... Read More

Advertisements