Articles on Trending Technologies

Technical articles with clear explanations and examples

Sum of the first N Prime numbers

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 4K+ 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 834 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 1K+ 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 252 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

Program to calculate area of Circumcircle of an Equilateral Triangle

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

A circumcircle is a circle that passes through all vertices of a polygon. For an equilateral triangle, the circumcircle can be calculated using the relationship between the triangle's side length and the circle's radius. Syntax Area = (π × a²) / 3 where a = side length of equilateral triangle Mathematical Formula The area of the circumcircle of an equilateral triangle with side length a is given by − Area = (π × a²) / 3 This formula is derived from the fact that the circumradius R of an equilateral triangle is ...

Read More

Program to calculate the area of an Circle inscribed in a Square

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

A circle inscribed in a square is a circle which touches all four sides of the square. The diameter of the inscribed circle is equal to the side of the square. The area can be calculated using the formula (π/4) × a² where 'a' is the length of side of square. Square with Inscribed Circle r = a/2 Side = a ...

Read More
Showing 21781–21790 of 61,298 articles
Advertisements