karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 47 of 143

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

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 Circumcircle of an Equilateral Triangle

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 291 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 781 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

Program to calculate area and perimeter of Trapezium

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

A trapezium is a quadrilateral that has at least one pair of parallel sides. The area and perimeter of a trapezium can be calculated using specific mathematical formulas. Syntax Perimeter = side1 + side2 + side3 + side4 Area = 0.5 * (parallel_side1 + parallel_side2) * height Formula Explanation Perimeter: Sum of all four sides of the trapezium Area: Half the product of the sum of parallel sides and the perpendicular distance between them Example This program calculates the area and perimeter of a trapezium using the given measurements − ...

Read More

Program to find the perimeter of a rhombus using diagonals

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

A rhombus is a quadrilateral where all four sides have equal length. The perimeter of a rhombus can be calculated using two methods: adding all sides or using the diagonal lengths. When using diagonals, we apply the mathematical relationship between the diagonals and side length. Syntax perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)); Where d1 and d2 are the lengths of the two diagonals. Mathematical Formula The perimeter of a rhombus using diagonals is calculated as: Perimeter = 2 × √(d1² + d2²) ...

Read More

Print a long int in C using putchar() only

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

Here we will see how to print long int value using the putchar() function in C. We can easily print the value of some variables using printf() in C, but here the restriction is, we cannot use any other function except putchar(). As we know that the putchar() is used to print only characters. We can use this function to print each digit of the number. When one numeric value is passed, we have to add character '0' with it to get the ASCII form. Syntax void print_long(long value); int putchar(int character); Example ...

Read More

How will implement Your Own sizeof in C

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

In C, the sizeof operator returns the size in bytes of a variable or data type. We can implement our own version of sizeof using pointer arithmetic. The concept is based on the fact that when we increment a pointer by 1, it moves by the size of the data type it points to. Syntax #define my_sizeof(variable) (char *)(&variable+1)-(char*)(&variable) How It Works The implementation uses pointer arithmetic − &variable gives the address of the variable &variable+1 gives the address after one complete element Casting both to (char*) makes the subtraction return bytes ...

Read More
Showing 461–470 of 1,421 articles
« Prev 1 45 46 47 48 49 143 Next »
Advertisements