How to print a formatted text using printf() method in Java?\

Vivek Verma
Updated on 29-May-2025 19:07:30

600 Views

In Java, formatted text refers to those text that has been processed and arranged according to a specific format. According to the article, we will use the printf() method to learn how to print the formatted text. Formatted Text using printf() Method In Java, to print the formatted output or text we have a printf() method. The printf() method allows us to format output to a java.io.PrintStream or java.io.PrintWriter. These classes also contain a method called format() which can produce the same results, so whatever we read here for the printf() method can also be applied to the format() method. ... Read More

What are the advantages of C++ Programming Language?

Akansha Kumari
Updated on 29-May-2025 19:06:43

4K+ Views

C++ is a general-purpose and high-level programming language, which was created by Bjarne Stroustrup in the early 1980s. It is an extension of the C programming language, which means it has features of C (procedural programming) with the added feature of object-oriented programming. It has become a widely used language, especially in competitive programming and is supported on most platforms such as Windows, Linux, Unix, and macOS. Advantages of C++ Programming LanguageIn this article we will discuss the advantages of using C++ language: C++ is a highly portable language that supports multi-device and multi-platform application ... Read More

How to call a JavaScript function from C++?

Akansha Kumari
Updated on 29-May-2025 19:05:56

1K+ Views

Calling a JavaScript function directly from C++ depends on the environment and the system; for this, make sure you have embedded a JavaScript engine or integrated C++ with JavaScript. In this article, we will be using Emscripten (C++ to JavaScript in WebAssembly) to call a JavaScript function from C++. For this, you have to compile the C++ program to WebAssembly using Emscripten and then call JavaScript functions from C++. So, first, create the C++ file with the header . C++ File Let's consider that this file name is saved as main.cpp. #include // here declared an external JS ... Read More

How can we read from standard input in Java?

Vivek Verma
Updated on 29-May-2025 19:05:27

38K+ Views

The standard input (stdin) can be represented by System.in in Java. The System.in is an instance of the InputStream class. It means that all its methods work on bytes, not Strings. To read any data from a keyboard, we can use either the Reader class or the Scanner class. Using Reader Class In Java, the Reader class is an abstract class belonging to the java.io package that is used for reading character streams. It is the superclass of all character input streams, such as "BufferedReader", "InputStreamReader", "FileReader", etc. Subclasses of Reader To use the functionality of the Reader class, use its ... Read More

How can we convert a hexadecimal value to a byte in Java?

Vivek Verma
Updated on 29-May-2025 19:03:15

313 Views

This article will discuss how to convert a hexadecimal value to a byte value in Java. Before converting it to a byte, let's first understand what hexadecimal and byte values are. Hexadecimal Value In Java, a hexadecimal number is a base-16 number represented using the digits 0-9 and the letters A-F or a-f, where A-F represent the decimal values 10-15 respectively. The hexadecimal values are: 0x1A 0xFF 0x0A Byte Value In Java, a byte is a data type that can store whole numbers between the ... Read More

How to find the number of days in a month of a particular year in Java?

Vivek Verma
Updated on 29-May-2025 18:58:51

2K+ Views

The given task is to find the number of days in a month of a particular year. To understand this, consider that if we can determine the maximum day value in a month, we can use that as the number of days in that month. To do this, we can use the GregorianCalendar class. It is a concrete subclass of the Calendar class, and it provides the standard calendar system used by most of the world. In Java, this GregorianCalendar can handle both the Gregorian calendar as well as Julian calendar. Following are the different ways to ... Read More

C++ set for user defined data type?

Akansha Kumari
Updated on 29-May-2025 18:57:55

525 Views

A set is a data structure that is used to store distinct values (meaning no two elements can have the same value) in ascending or descending order. Set for User-defined Data TypesWe can directly use sets for built-in data types, but for user-defined data types, values cannot be directly stored, because a set compares the elements to maintain order, but for user-defined data types such as array or struct, the compiler will not be able to perform a comparison between them. The set container is defined under the header file. So to use user-defined datatypes into a stack, we ... Read More

Data Type Ranges and their macros in C++

Akansha Kumari
Updated on 29-May-2025 18:56:08

2K+ Views

In some cases, especially in competitive programming, we may need to specify the minimum or maximum value of a specific datatype. In C++, each data type has a different memory range under which we can define and declare the value of that data type. But it becomes difficult to remember all the large ranges of each data type. So, C++ has introduced the macros that are used to represent the minimum and maximum range of some datatype. And some data types do not have macros for minimum values, because they are unsigned (means, hold only positive value). So, as their ... Read More

How To Check Whether a Number Is a Fascinating Number or Not in Java?

Vivek Verma
Updated on 29-May-2025 18:48:33

5K+ Views

What is Fascinating Numbers? A Fascinating number is a number if the result of concatenation of the (original) number with its multiples of 2 and 3 contains all the digits from 1 to 9. For example, we have the number 192. Its product with 2 is 384, and with 3 is 576. Now concatenate (don't add) these with the original number: "192" + "384" + "576" = "192384576", which contains all the digits from 1 to 9 exactly once. Here are some other fascinating numbers, suchas: 192, 1920, 2019, 327, etc. Note: For a number to be a fascinating number, ... Read More

How To Check Whether a Number is a Evil Number or Not in Java?

Vivek Verma
Updated on 29-May-2025 18:24:59

4K+ Views

What is Evil Number? In mathematical terms, an Evil number is a number whose binary representation has exactly an even number of 1's present in it. For example, the binary representation of 3 is 0011. So the number 1's is even the number 3 is an evil number. A binary number is a number expressed in the base-2 numeral system, it is also known as the binary numeral system. It is always represented using two digits: 0 and 1. Each digit (0, 1, 2, 3, ...), character (a, A, b, c, D, ...Z), and symbol (@, #, $, ...) used ... Read More

Advertisements