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
C Articles
Page 75 of 96
1 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 MoreArea of circle inscribed within rhombus?
A circle inscribed in a rhombus touches all four sides of the rhombus. Each side of the rhombus acts as a tangent to the inscribed circle. To find the area of this inscribed circle, we need the lengths of the rhombus diagonals. r a b O ...
Read MoreArea of a Circular Sector?
A circular sector (also known as a circle sector or sector of a circle) is the portion of a circle that is enclosed between two radii and an arc. To find the area of a circular sector, we need to determine the central angle between the two radii. r θ Sector Syntax Area = π × r² × (θ / 360°) Where: π (pi) ≈ 3.14159 r = radius of ...
Read MoreArea of a circle inscribed in a regular hexagon?
In C programming, calculating the area of a circle inscribed in a regular hexagon involves understanding the geometric relationship between the hexagon and its inscribed circle. A circle inscribed in a regular hexagon touches all six sides of the hexagon at their midpoints. Syntax area = (3 * π * side * side) / 4 Mathematical Formula For a regular hexagon with side length a, the radius of the inscribed circle is r = a(√3)/2. Using the circle area formula A = πr², we get − ...
Read MoreC program to find Decagonal Number?
A decagonal number is a figurate number that represents the number of dots that can be arranged in nested decagonal (10-sided) patterns. These numbers follow the formula 4n² - 3n, where n is the position in the sequence. For example, the 3rd decagonal number involves arranging dots in 3 nested decagons. Each nested layer contributes a specific number of dots, and we subtract the overlapping dots to get the final count. Decagonal Number Pattern ...
Read MoreAverage of even numbers till a given even number?
To find the average of even numbers till a given even number, we need to sum all the even numbers up to that number and divide by the count of even numbers. Syntax average = sum_of_even_numbers / count_of_even_numbers Example Average of even numbers till 10 is calculated as − Even numbers: 2, 4, 6, 8, 10 Sum: 2 + 4 + 6 + 8 + 10 = 30 Count: 5 Average: 30 ÷ 5 = 6 There are two methods for calculating the average of even numbers till n (where n is ...
Read More