Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
C/C++ Program for Maximum height when coins are arranged in a triangle?
In this section, we will see one interesting problem. There are N coins, and we have to find the maximum height we can make if we arrange the coins as a pyramid. In this fashion, the first row will hold 1 coin, the second will hold 2 coins, and so on. Coin Pyramid 1 1 1 1 ...
Read Morec32rtomb() function in C/C++?
In C programming, the c32rtomb() function is used to convert a 32-bit wide character (char32_t) to its corresponding multibyte character representation. This function is defined in the uchar.h header file and is part of the C11 standard for Unicode support. Syntax size_t c32rtomb(char *s, char32_t c32, mbstate_t *ps); Parameters s − Pointer to a character array where the multibyte character will be stored c32 − The 32-bit wide character to convert ps − Pointer to an mbstate_t object that holds the conversion state Return Value The function returns the number ...
Read MoreA data structure for n elements and O(1) operations?
Here we will see one data structure with n elements, and O(1) operations. So the operations will take constant amount of time to execute. The data structure will hold n elements (from 0 to n-1). The data can be in any order. The insertion, deletion and searching will take O(1) amount of time. To solve this problem, we will use one Boolean array. This will indicate that the item is present or not at position i. If the item is present, it will hold 1, otherwise 0. Syntax void init(bool dataStructure[], int n); ...
Read MoreA C Programming Language Puzzle?
Here we will see one C programming language puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that? This is easy. We can do by using Token Pasting operator(##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the ...
Read More2's compliment for a given string using XOR ?
In C programming, finding the 2's complement of a binary string can be efficiently done using the XOR operation. The 2's complement is calculated as 1's complement + 1. We use XOR to flip bits and implement a specific algorithm that traverses from the least significant bit (LSB). Syntax char* get2sComplement(char* binaryString); Algorithm The algorithm works by traversing the binary string from right to left − Ignore all trailing zeros until we find the first '1' Keep the first '1' unchanged Flip all remaining bits using XOR operation If no '1' is ...
Read More1 to n bit numbers with no consecutive 1s in binary representation?
In this problem, we need to count binary numbers of n bits that contain no consecutive 1s in their binary representation. For example, in 3-bit binary strings, numbers like 011, 110, and 111 have consecutive 1s, while 5 numbers (000, 001, 010, 100, 101) do not have consecutive 1s. The solution uses dynamic programming with two arrays: one tracking numbers ending with 0 and another tracking numbers ending with 1. Syntax int countBinaryNumbers(int n); Algorithm The recurrence relations are − endWithZero[i] = endWithZero[i-1] + endWithOne[i-1] (we can append 0 to any ...
Read More# and ## Operators in C ?
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 Moreattribute((constructor)) and attribute((destructor)) syntaxes in C in tutorials point ?
Here we will see how to write a code where two functions are present, and one function will be executed before the main function, and another function will be executed after main function. These features are used to do some startup task before executing main, and some clean up task after executing main. To do this task we have to put attribute for these two functions. When the attribute is constructor attribute, then it will be executed before main(), and when the attribute is destructor type, then it will be executed after main(). We are using GCC functions. ...
Read MoreArea of Circumcircle of a Right Angled Triangle?
The area of circumcircle of a right-angled triangle can be calculated when the hypotenuse (H) of the triangle is given using the formula πH²/4. This formula is derived from the fact that in a right-angled triangle, the hypotenuse is the diameter of the circumcircle. The circumcircle passes through all three vertices of the triangle. For a right-angled triangle, the hypotenuse becomes the diameter because the angle inscribed in a semicircle is always 90°. Since the area of a circle is πr², and diameter d = 2r, we can write the area as πd²/4, where d is replaced by the ...
Read MoreArea of circle which is inscribed in an equilateral triangle?
The area of a circle inscribed inside an equilateral triangle is found using the mathematical formula πa2/12, where 'a' is the side length of the triangle. Syntax area = π × a² / 12 Formula Derivation Let's see how this formula is derived − Step 1: Find the radius of the inscribed circle using the formula: Radius = Area of triangle / Semi-perimeter of triangle Step 2: For an equilateral triangle with side 'a': Area of triangle = (√3)a2/4 Semi-perimeter = 3a/2 Step 3: Calculate the radius: Radius = ...
Read More