Articles on Trending Technologies

Technical articles with clear explanations and examples

C Programming for Sum of sequence 2, 22, 222, .........

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 1K+ Views

Given is a sequence: 2, 22, 222, 2222… and we need to find the sum of this sequence. We need to derive a mathematical formula to calculate the sum efficiently. Syntax sum = 2 * (pow(10, n) - 1 - (9 * n)) / 81; Mathematical Derivation The formula derivation follows these steps − sum = [2 + 22 + 222 + 2222 + ...] sum = 2 * [1 + 11 + 111 + 1111 + ...] sum = 2/9 * [9 + 99 + 999 + 9999 + ...] sum ...

Read More

Usage of :first-child pseudo-class in CSS

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 99 Views

The CSS :first-child pseudo-class is used to select and style an element that is the first child of its parent element. This selector only targets the very first child element, regardless of its type. Syntax selector:first-child { property: value; } Example: Basic Usage The following example demonstrates how :first-child selects the first paragraph inside a div element − div > p:first-child { text-indent: 25px; ...

Read More

Sum of the numbers up to N that are divisible by 2 or 5 in c programming

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 568 Views

Finding the sum of numbers up to N that are divisible by 2 or 5 can be efficiently calculated using the inclusion-exclusion principle. Instead of iterating through all numbers, we use mathematical formulas to compute the sum in O(1) time complexity. Syntax sum = sum_divisible_by_2 + sum_divisible_by_5 - sum_divisible_by_10 Mathematical Approach The solution uses three formulas based on arithmetic progression − Sum of numbers divisible by 2: Sum2 = ((n / 2) * (4 + (n / 2 - 1) * 2)) / 2 Sum of numbers divisible by 5: Sum5 = ...

Read More

Commonly used pseudo-classes in CSS

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 549 Views

CSS pseudo-classes allow you to style elements based on their state or position without adding extra classes to your HTML. These powerful selectors help create interactive and dynamic styling effects. Syntax selector:pseudo-class { property: value; } Commonly Used Pseudo-Classes Pseudo-ClassDescription :linkStyles unvisited links :visitedStyles visited links :hoverStyles elements when mouse hovers over them :activeStyles elements when being clicked/activated :focusStyles elements that have keyboard focus :first-childStyles the first child element of its parent :langStyles elements based on their language attribute Example: Link States The following example demonstrates ...

Read More

Sum of the nodes of a Singly Linked List in C Program

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 4K+ Views

A singly linked list is a data structure where each node contains two parts: the data value and a pointer to the next node. To find the sum of all elements in a singly linked list, we traverse each node and add its value to a sum variable. For example Suppose we have a linked list: 2 −> 27 −> 32 −> 1 −> 5 sum = 2 + 27 + 32 + 1 + 5 = 67 Syntax struct Node { int data; struct ...

Read More

Usage of :hover pseudo-class in CSS

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 144 Views

The :hover pseudo-class is used to add special styles to an element when a user hovers their mouse cursor over it. This creates interactive effects that enhance user experience and provide visual feedback. Syntax selector:hover { property: value; } Example: Link Hover Effect The following example changes the color of a link when you hover over it − a { color: #0066cc; text-decoration: none; ...

Read More

Sum of the first N terms of the series 2, 6, 12, 20, 30.... in c programming

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 444 Views

In C programming, we can find the sum of the series 2, 6, 12, 20, 30… by analyzing its pattern. Each term can be expressed as n + n² where n is the position. Syntax sum = n*(n+1)/2 + n*(n+1)*(2*n+1)/6 Series Analysis Let's analyze the given series − Series: 2, 6, 12, 20, 30... Term 1: 2 = 1 + 1² = 1 + 1 Term 2: 6 = 2 + 2² = 2 + 4 Term 3: 12 = 3 + 3² = ...

Read More

Usage of margin property with CSS

George John
George John
Updated on 15-Mar-2026 116 Views

The CSS margin property defines the space around an HTML element, creating transparent area outside the element's border. It is possible to use negative values to overlap content and it serves as a shorthand property for setting all margin properties in one declaration. Syntax selector { margin: value; } Possible Values ValueDescription lengthDefines margin in px, em, rem, etc. %Defines margin as percentage of container width autoBrowser calculates the margin automatically inheritInherits margin from parent element Example 1: Single Value Margin The following example applies 20px ...

Read More

Sum of first n natural numbers in C Program

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 1K+ Views

In C programming, finding the sum of the first n natural numbers is a common problem that can be solved using different approaches. The sum of first n natural numbers means adding all positive integers from 1 to n (i.e., 1 + 2 + 3 + ... + n). For example, if n = 5, then the sum would be: 1 + 2 + 3 + 4 + 5 = 15 Syntax sum = n * (n + 1) / 2 We have two main methods to calculate this sum − Method ...

Read More

Usage of :visited pseudo-class in CSS

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 101 Views

The :visited pseudo-class is used to add special styling to links that have already been visited by the user. This allows you to provide visual feedback indicating which links have been previously clicked. Syntax a:visited { property: value; } Possible Values PropertyDescription colorChanges the text color of visited links background-colorChanges the background color of visited links text-decorationAdds or removes underlines, strikethrough, etc. Example The following example changes the color of visited links to green − a:link ...

Read More
Showing 21591–21600 of 61,297 articles
Advertisements