Difference Between Void in C and C++

Revathi Satya Kondra
Updated on 10-Jun-2025 14:27:29

628 Views

Both languages (C and C++) support void pointers, but their behaviour is different. In C, a void pointer can be directly assigned to any other pointer type without the need for a typecast. However, in C++, assigning a void pointer to any other pointe type require an explicit typecast. In this article, we will learn the differences between void pointers in C and C++.. Void Pointer in C A void pointer (also called a generic pointer) in C is a special type of pointer that can point to any data type, but doesn’t have any type by itself. It ... Read More

Iterate Over ArrayList Using Lambda Expression in Java

Aishwarya Naglot
Updated on 10-Jun-2025 14:26:28

3K+ Views

The ArrayList class is a resizable array that can be found in java.util package. The difference between a built-in array and an ArrayList in Java is that the size of an array cannot be modified. Lambda Expression is a feature that was introduced in Java 8. It is useful when we use collections, such as ArrayList, Set, or Map, and we want to perform operations on the elements of these collections. In this article, we will learn how to iterate over an ArrayList using a lambda expression in Java. Iterating Over an ArrayList Using Lambda Expressions There are two main ... Read More

Wide Char and Library Functions in C++

Revathi Satya Kondra
Updated on 10-Jun-2025 13:24:03

4K+ Views

Wide Characters Wide characters are similar to character datatype. The main difference is that char takes 1-byte space, but wide character takes 2-bytes (sometimes 4-byte depending on compiler) of space in memory. For 2-byte space wide character can hold 64K (65536) different characters. So the wide char can hold UNICODE characters. The UNICODE values are international standard which allows for encoding for characters virtually for any character of any language. Example 1: Size of a single wide character This program demonstrates how to declare a single wide character using wchar_t to print its value and memory size. #include using namespace ... Read More

Return from Void Functions in C++

Revathi Satya Kondra
Updated on 10-Jun-2025 13:16:07

18K+ Views

The void functions are called void because they do not return anything. "A void function cannot return anything" this statement is not always true. From a void function, we cannot return any values, but we can return something other than values. Some of them are like below. A void function can return A void function cannot return any values. But we can use the return statement. It indicates that the function is terminated.ExampleThe following example demonstrates a void function with the return statement: #include using namespace std; void my_func() { cout

Exception Handling and Object Destruction in C++

Revathi Satya Kondra
Updated on 10-Jun-2025 13:11:44

889 Views

In this article, you will learn what is exception handling, object destruction, and Handing exception thrown in Object Destructor in C++. C++ Exception Handling An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. C++ exception handling is built upon three keywords: try, catch, and throw. try: This block contains the code ... Read More

Find Length of Hypotenuse in Java

Vivek Verma
Updated on 10-Jun-2025 12:16:51

2K+ Views

Hypotenuse refers to the longest side, which is opposite to the right angle of a right-angled triangle. Following is the diagram of the Hypotenuse: Length of the Hypotenuse The length of the hypotenuse can be calculated using the Pythagorean theorem. According to it, the sum of the squares of the lengths of two sides is equal to the square of the length of the third side as follows: a2 + b2 = c2 c = √(a2 + b2) Where a, b, and c refer to the three sides of the right-angled triangle. You can write the above formula ... Read More

Python Program for 0-1 Knapsack Problem

Sarika Singh
Updated on 10-Jun-2025 11:59:57

5K+ Views

Knapsack is a classic problem that involves decision-making based on constraints. Suppose we have a knapsack with fixed capacity, and items with fixed values and sizes (it might be volume of the item or weight). We need to add items into the knapsack such that we pack the maximum value items. From the available combinations, we need to provide an optimized solution. There are three types of knapsack problems 0-1 Knapsack: We can either pick an item or not (0 or 1). Fractional Knapsack: We can pick a part of an ... Read More

Load a File into the JShell Session in Java 9

Alshifa Hasnain
Updated on 09-Jun-2025 19:30:05

2K+ Views

In this article, we will learn to load a file into the JShell session in Java 9. We will learn about Jshell and different ways we can load a file in Jshell, which is the command line and the /open command. What is a JShell? JShell is a new command-line interactive REPL (Read-Evaluate-Print-Loop) tool introduced in Java 9 to evaluate declarations, statements, and expressions written in Java. This tool also allows us to execute Java code snippets and get immediate results. Loading a file into the JShell There are two ways to load a file into the JShell session in ... Read More

Implement Lambda Expression in JShell in Java 9

Alshifa Hasnain
Updated on 09-Jun-2025 19:29:50

366 Views

In this article, we will learn to implement a lambda expression in JShell in Java 9. We will learn the syntax, explain the working of lambda expressions, and how they work with functional interfaces, and give examples with the JShell environment. JShell JShell is Java's first REPL and command-line tool that provides interactive use of Java programming language elements. We can test the functionality in isolation of a class by using this tool. JShell creates a simple and easy programming environment in the command-line that takes input from the user, reads it, and prints the result. What is a ... Read More

New Methods Added to the String Class in Java 9

Alshifa Hasnain
Updated on 09-Jun-2025 19:29:15

266 Views

In this article, we will learn about the new methods added to the String class in Java 9. We will learn about Strings and the new methods in the String class, along with examples. Strings A String is the type of object that contains a collection of characters enclosed by double quotes (" "). The Java platform provides the String class to create and manipulate strings in Java. The String class is immutable, so that once it is created, a String object cannot be changed. String is the only class where operator overloading is supported in Java, we can concatenate ... Read More

Advertisements