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
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
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
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
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
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
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
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
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
A tetrahedron is a pyramid with a triangular base i.e. it has a base that is a triangle and each side has a triangle. All the three triangles converge to a point. As shown in the figure − Base (triangle) Apex a The code to find the area and volume of tetrahedron uses the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance