Vivek Verma

Vivek Verma

84 Articles Published

Articles by Vivek Verma

Page 2 of 9

Write a program to find the index of particular element in an array in javascript?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 1K+ Views

Finding the index of a particular element in an array is a common task in JavaScript. An array is an object that contains multiple values in a sequential order, with each element having a specific index position. 22 45 67 89 12 0 1 2 3 4 Array Elements Index ...

Read More

Write a palindrome program in JavaScript so that only alphanumeric values should be allowed?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 971 Views

A palindrome is a string that reads the same forwards and backwards. When checking palindromes with alphanumeric characters only, we need to ignore spaces, punctuation, and special characters, considering only letters (a-z) and digits (0-9). For example, "A man, a plan, a canal: Panama" becomes "amanaplanacanalpanama" after removing non-alphanumeric characters, which is indeed a palindrome. Basic Palindrome Check Here's a simple approach using string manipulation methods to check if a string is a palindrome: var str = "racecar"; ...

Read More

How to create custom range sliders with CSS and JavaScript?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 1K+ Views

A range slider is an HTML input element that accepts the type "range". It allows users to select a numeric value within a specified range by dragging a slider handle. Syntax input[type="range"] { -webkit-appearance: none; width: 300px; height: 20px; background: #ddd; border-radius: 5px; } input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; background: #007bff; border-radius: 50%; ...

Read More

# and ## Operators in C ?

Vivek Verma
Vivek Verma
Updated on 15-Mar-2026 4K+ Views

In C, the "#" and "##" are preprocessor operators that are used to manipulate macro parameters during compilation. The # operator converts a macro parameter to a string literal, while the ## operator concatenates two tokens into a single token. The macro parameters are the parameters of the macro definition, which are declared using the #define directive. The "#" operator is known as the Stringizing operator, whereas the "##" operator is known as the Token Pasting operator. Syntax /* Stringizing operator */ #define MACRO_NAME(param) #param /* Token pasting operator */ #define MACRO_NAME(param1, param2) param1##param2 ...

Read More

How to remove the HTML tags from a given string in Java?

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 20K+ Views

A String is a final class in Java, and it is immutable, it means that we cannot change the object itself, but we can change the reference to the object. The HTML tags can be removed from a given string by using the following approaches: Using replaceAll() Method Using Pattern and Matcher Using replaceAll() Method We can remove the HTML tags from a given string by using the replaceAll() method. The replaceAll() method accepts two parameters: a "regular expression" and a "replacement string". It replaces all substrings that match the ...

Read More

How can we convert character array to a Reader in Java?

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 498 Views

Converting a character array to a reader in Java means treating the array as a stream of characters to be read sequentially. Let's quickly learn about character array and its creation in Java: In Java, a character array is an array that holds elements of only char type, and it is also used to store a sequence of characters. Following is the syntax to define a character array in Java: char char_array_name[] = {'char1', 'char2', 'char3'....} or char char_array_name[] = new char[size]; Here, char_array_name: The name of the character array. ...

Read More

Can a constructor be synchronized in Java?

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 2K+ Views

No, a constructor cannot be synchronized in Java. If you try to use the synchronized keyword before a constructor, it may throw a compile-time error in the IDE. Synchronization is a mechanism used to control the access of multiple threads to any shared resource. When multiple threads access any shared resources, the synchronization prevents data corruption by coordinating access, avoiding race conditions (i.e., occurs when multiple threads concurrently access and modify shared data), and ensuring that operations are performed atomically. The JVM ensures that only one thread can invoke a constructor call at a given point in time. That is ...

Read More

Can we define a package after the import statement in Java?

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 736 Views

No, we cannot define a package after the import statement in Java. The compiler will throw an error if we try to insert a package after the import statement. A package is a group of similar types of classes, interfaces, and sub-packages. To create a class inside a package, declare the package name in the first statement in our program. Important! If you use the package statement in an online compiler, you may still get an error even if it is defined correctly. This is because many online compilers do not support custom package structures. Example In the following example, ...

Read More

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

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 3K+ Views

What is a Narcissistic Number? A number is said to be a Narcissistic number, only if the addition (or sum) of the value of each digit raised to the power of the total number of digits available in the original number is equal to the original number. Examples of narcissistic numbers, such as 153, 1634, 54748, etc. All single-digit numbers (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) are Narcissistic numbers because the power of 1 of any digit will be the digit itself. The following input and output scenarios will help you understand the problem and calculation ...

Read More

Compiling a C++ program with GCC

Vivek Verma
Vivek Verma
Updated on 28-Aug-2025 32K+ Views

To compile a C++ program with GCC, we need to download GCC or install the g++ compiler on our system. Otherwise, you will not be able to compile C++ code using GCC. What is GCC? The GCC is a tool chain that compiles code. It stands for GNU Compiler Collection, which was developed by the GNU project. The GCC supports various programming languages such as C, C++, Go, etc. Specific to the C++ language, the GCC provides the g++ compiler, which is developed or designed to compile the C++ source code into executable programs. Note: When the C++ program compiles ...

Read More
Showing 11–20 of 84 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements