Variable-length arrays (VLAs) in C allow you to create arrays whose size is determined at runtime rather than compile time. This feature was introduced in C99 and provides dynamic array allocation on the stack. In this example, we'll demonstrate a library system that uses VLAs to manage books on shelves with three operations: adding books, querying book pages, and counting books per shelf. Syntax data_type array_name[variable_size]; // Where variable_size is determined at runtime Library Management System The system supports three commands − Command 1: Insert a book with y pages at shelf ... Read More
We can create an image with transparent background text by overlaying text content on an image using CSS positioning and background transparency. This technique uses a semi-transparent background color with the rgba() function to create an overlay effect that makes text readable while keeping the background image visible. Syntax .text-overlay { background: rgba(red, green, blue, alpha); position: absolute; } Method 1: Bottom Overlay Text This approach positions the text overlay at the bottom of the image with a transparent background − ... Read More
Suppose we are given two integers k and n. Our task is to perform three operations; bitwise AND, bitwise OR, and bitwise XOR between all pairs of numbers up to range n. We return the maximum value of all three operations between any two pairs of numbers that is less than the given value k. So, if the input is like n = 5, k = 5, then the output will be 4 3 4. The greatest value of AND, OR, and XOR operations between all pairs of numbers that are less than 5 are 4, 3, and ... Read More
Suppose we have an array of different triangles where triangles[i] = [ai, bi, ci] these are the sides of ith triangle. We shall have to sort the triangles based on their area. The area of a triangle using sides is calculated with Heron's formula: square root of p*(p-a)*(p-b)*(p-c) where p = (a+b+c)/2. So, if the input is like (7, 24, 25), (5, 12, 13), (3, 4, 5), then the output will be (3, 4, 5), (5, 12, 13), (7, 24, 25) Syntax struct Triangle { int a, b, c; }; int ... Read More
The CSS filter property is used to apply visual effects to images such as blur, brightness, contrast, drop shadow, grayscale, and more. This property allows you to enhance or modify the appearance of images directly through CSS without needing image editing software. Syntax selector { filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url(); } Common Filter Effects Filter FunctionDescriptionValues blur()Applies blur effectpx values (e.g., 5px) brightness()Adjusts brightness0% to 100%+ (100% = normal) contrast()Adjusts ... Read More
Variadic functions in C allow you to create functions that can accept a variable number of arguments. This is useful when you need functions like sum(), max(), and min() that can work with different numbers of input values. To implement variadic functions, we use the ellipsis (...) notation and include the header file. Syntax return_type function_name(fixed_parameter, ...); The key macros for handling variable arguments are − va_list: Stores information about variable arguments va_start: Initializes the va_list to start accessing arguments va_arg: Retrieves the next argument of specified type va_end: Cleans up the ... Read More
The image overlay zoom effect on hover creates a smooth animation where a colored overlay scales up when the mouse cursor hovers over an image. This effect uses the :hover selector combined with CSS transforms and transitions to create an engaging visual interaction. Syntax .container:hover .overlay { transform: scale(1); transition: transform duration ease-function; } HTML Structure First, create a container with an image and overlay div ? Caption Text ... Read More
In C, generating permutations of strings means finding all possible arrangements of a given array of strings. We can use the next permutation algorithm to systematically generate all permutations in lexicographical order. Syntax int next_permutation(int n, char **strings); Algorithm The next permutation algorithm works by − Finding the rightmost element that is smaller than its next element Finding the smallest element on the right side that is larger than the found element Swapping these two elements Reversing the sequence after the original smaller element Example Let us see the ... Read More
In C, finding the frequency of each digit in a string involves scanning through the string character by character and counting occurrences of digits (0-9). We use an array to store the frequency count for each digit. Syntax int freq[10] = {0}; // Array to store frequency of digits 0-9 if (str[i] >= '0' && str[i] = '0' && s[i] 0) { printf("(Number %d, Freq %d)", i, freq[i]); } } } ... Read More
The image overlay effect on hover is hidden when the page loads and becomes visible when the mouse cursor is hovered over the image. The smooth transition effect is achieved using the CSS transition property combined with opacity and position properties. Syntax .overlay { transition: duration ease; opacity: 0; position: absolute; } .container:hover .overlay { opacity: 1; } Method 1: Basic Overlay with Text This method creates a simple text overlay that appears centered over the image ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance