Both C and C++ are powerful programming languages that are used by developers to write both system-level and high-level programs. C language follows procedural programming paradigm with a simple and structured approach, whereas C++ supports both procedural and object-oriented programming. Although both C and C++ are widely used across various fields for developing different types of system and application software but they have different strength and use cases. In this article, we will learn when to use C over C++, and when C++ is a better choice than C. When to use C Language? When ... Read More
In this article, we will see how to get the Host name and IP address of the local system in an easier way using C and C++ program. Getting IP Address of Local Computer For this, some standard networking functions are available in socket programming with header files like on Windows and , , on Linux. In this article we will mainly discuss three commonly used functions: Sr.No ... Read More
A structures (or struct) is a user-defined data type, which is used to group and store variables of different data types inside a single name. But in C, structures can store only data members whereas C++ can store member functions, constructors, destructors, and even inheritance which is similar to classes in C++, but the only difference between struct and classes is that struct members are public by default. In this following article we will see how structure differs in both C and C++ in detail. Structures in C The structures in C is a user-defined data type, which is used ... Read More
In this article, we will learn about the use of the Optional.stream() method in Java 9. First, we will learn about the optional class and its method. Then we will see the use cases along with an example.Optional class The Optional class was introduced in Java 8 to reduce the null pointer exception that occurs in Java. It is basically a container for the actual object that needs to be returned by a method. The point here is that if a method returns a null value, which can be null, then that method could return a value instead contained inside ... Read More
What is JLink? Java Linker is a new linker tool that has been used to create our own customized JRE. Usually, we can run our program using default JRE provided by Oracle. If we need to create our own JRE then use this tool. JLink tool can help to create its own JRE with only the required class to run the application. It can reduce the size of the API developed and the dependency of using the full JRE. In Java 9, we have a new phase between compiling the code and its execution, link time. Link time is an optional phase between the phases of ... Read More
JShell is a REPL interactive tool introduced in Java 9 to execute and evaluate simple Java programs like variable declarations, statements, expressions, and programs without using the main() method.In this article, we will learn to create scratch variables in JShell in Java 9. Variables in JShell In Java 9, JShell allows for the declaration and use of variables without the need for a surrounding class or method structure. One may be able to explicitly declare the variable with a type, or else it might be declared implicitly using var for type inference. C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 ... Read More
When working with floating-point numbers in C++, it's important to know how to control the number of decimal places displayed in the output. By default, cout may not always print the expected number of digits after the decimal point.How to Print Correct Number of Decimal Points with cout?To display numbers with a specific number of decimal places using cout, you can use the setprecision() function, which accepts an integer value representing the number of digits after the decimal to be printed and returns a stream manipulator that formats the number with the specified precision. The setprecision() function belongs to the ... Read More
Leading whitespace refers to any spaces, tabs, or other blank characters that appear at the start of a string. These characters come before the first visible text and can affect how the string is displayed. We can remove all leading whitespace from a string in Python using the lstrip() function. Using the lstrip() Function The lstrip() function removes all whitespace characters from the beginning (left side) of a string (leading whitespace). It does not affect any whitespace at the end or in the middle of the string. There are also two related functions i.e. rstrip() and strip() - ... Read More
We can convert all uppercase letters in a string to lowercase in Python using the lower() function. You can also use a for loop or list comprehension to change each character to lowercase one by one. This is helpful when you want to compare strings without worrying about letter cases. Using lower() Function The Python lower() function returns a new string with all uppercase letters converted to lowercase, keeping the lowercase letters unchanged. It does not modify the original string and is commonly used when comparing strings or handling user input. Example In the following example, we convert an entire string ... Read More
In Python, you can replace all occurrences of a substring within a string using the replace() method. This method returns a new string where every occurrence of the given old substring is replaced with a new substring. To match the string with case-insensitivity, you need to use regular expressions. Using the replace() Method The Python replace() method returns a new string where all occurrences of the old substring are replaced with the new substring. It does not modify the original string because strings in Python are immutable. string.replace(oldvalue, newvalue, count) where, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP