Programming Articles

Page 993 of 2547

Area of the largest triangle that can be inscribed within a rectangle?

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 759 Views

A rectangle is a quadrilateral that has opposite sides equal and parallel, with adjacent sides at 90°. A triangle is a closed figure with three sides. The largest triangle that can be inscribed within a rectangle has its base equal to the length of the rectangle and height equal to the breadth of the rectangle. This triangle spans the entire diagonal of the rectangle. Length (l) Breadth (b) Largest Triangle ...

Read More

1's and 2's complement of a Binary Number?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 5K+ Views

Binary numbers are expressed in base 2, using only the digits '0' and '1'. Each digit in a binary number is called a bit. Understanding 1's and 2's complement is essential for representing signed numbers in computer systems. 1's Complement One's complement of a binary number is obtained by inverting all bits − changing every '0' to '1' and every '1' to '0'. Syntax 1's complement = invert all bits Example: 101100 → 010011 2's Complement Two's complement of a binary number is obtained by adding 1 to the 1's complement of ...

Read More

Sum of the first N Prime numbers

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 3K+ Views

In C programming, finding the sum of the first N prime numbers involves identifying prime numbers sequentially and adding them together. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Syntax int isPrime(int num); int sumOfFirstNPrimes(int n); Algorithm The approach involves checking each number starting from 2 for primality, and when a prime is found, adding it to the sum until we have found N primes − Start with the first prime number (2) Check each subsequent number for primality Add ...

Read More

Sum of first N natural numbers which are divisible by X or Y

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 775 Views

The sum of first N natural numbers which are divisible by X or Y involves finding all numbers from 1 to N that are multiples of either X or Y, then adding them together. This is a common problem in competitive programming and mathematical computations. Syntax // Method 1: Loop approach for(int i = 1; i

Read More

C Program to Add two Integers

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 1K+ Views

A program to add two integers takes two numbers, performs their mathematical sum, and stores the result in another variable. Syntax int sum = number1 + number2; Method 1: Adding Fixed Values This approach demonstrates adding two predefined integer values − #include int main() { int a = 545; int b = 123; int sum = a + b; printf("The first number is %d", a); ...

Read More

C Program for Program to find the area of a circle?

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 17K+ Views

The area is a quantity that represents the extent of the figure in two dimensions. The area of a circle is the area covered by the circle in a two-dimensional plane. To find the area of a circle, the radius [r] or diameter [d] (2 × radius) is required. The formula used to calculate the area is (π × r2) or {(π × d2)/4}. Syntax area = π × radius × radius area = (π × diameter × diameter) / 4 Method 1: Finding Area Using Radius This method calculates the circle area ...

Read More

Add 1 to a given number?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 1K+ Views

Adding 1 to a given number is a fundamental operation in C programming that increments a variable's value by one. This operation is commonly used in loops, counters, and iterative processes. Syntax variable = variable + 1; // Method 1: Addition assignment variable++; // Method 2: Post-increment ++variable; // Method 3: Pre-increment There are multiple methods to add 1 to a given number in C ...

Read More

Average of first n even natural numbers?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 1K+ Views

The average of first n even natural numbers is the sum of the numbers divided by the count of numbers. The first n even natural numbers are 2, 4, 6, 8, ..., 2n. Syntax Average = Sum of first n even numbers / n You can calculate this using two methods − Find the sum of n even natural numbers using a loop and divide by n Use the mathematical formula for direct calculation Method 1: Using Loop This method iterates through the first n even numbers, calculates their sum, ...

Read More

Program to calculate Area Of Octagon

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 937 Views

An octagon is a polygon with eight sides. To calculate the area of a regular octagon, we use a specific mathematical formula based on the side length. Syntax Area = 2 * (1 + √2) * side² Where side is the length of one side of the regular octagon. Formula Explanation The area of a regular octagon can be calculated using the formula − Area = 2 * (1 + √2) * a² Where: a is the side length of the octagon √2 is approximately 1.414 The coefficient 2 * ...

Read More

Program to calculate area of Enneagon

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 213 Views

An enneagon (also known as nonagon) is a polygon with 9 sides. To calculate the area of an enneagon, we use a specific mathematical formula based on the side length. Syntax Area = (a² × 9) / (4 × tan(20°)) Area ≈ 6.1818 × a² Where a is the length of each side of the enneagon. ...

Read More
Showing 9921–9930 of 25,466 articles
« Prev 1 991 992 993 994 995 2547 Next »
Advertisements