Mandalika

Mandalika

409 Articles Published

Articles by Mandalika

Page 2 of 41

Write a C program to find out the largest and smallest number in a series

Mandalika
Mandalika
Updated on 15-Mar-2026 19K+ Views

In C programming, finding the largest and smallest numbers in a series is a fundamental problem that can be solved using conditional statements or arrays. This involves comparing each number with the current maximum and minimum values to determine the extremes. Syntax if (number > max) max = number; if (number < min) min = number; Method 1: Using Four Variables This approach reads four numbers from the user and compares them to find the largest and smallest − #include int main() ...

Read More

Write a C program for time conversions using if and elseif statements

Mandalika
Mandalika
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will learn how to convert time from 24-hour format (also known as military time) to 12-hour format using C programming with if and else if statements. The 24-hour format uses hours from 00 to 23, while the 12-hour format uses hours from 1 to 12 with AM/PM indicators. Syntax if (condition1) { // statements } else if (condition2) { // statements } else { // statements } Algorithm Start: Step 1: Enter time in 24 hr format ...

Read More

How to print the stars in Diamond pattern using C language?

Mandalika
Mandalika
Updated on 15-Mar-2026 804 Views

In C programming, printing a diamond pattern with stars is a common pattern printing problem that helps understand nested loops and spacing logic. A diamond pattern consists of an upper triangular half followed by a lower triangular half. Syntax // Upper half pattern for (j = 1; j

Read More

How to calculate transpose of a matrix using C program?

Mandalika
Mandalika
Updated on 15-Mar-2026 54K+ Views

The transpose of a matrix is obtained by converting rows to columns and columns to rows. If A is an original matrix and B is its transpose, then element at position A[i][j] becomes B[j][i]. Syntax for (i = 0; i < rows; i++) for (j = 0; j < cols; j++) transpose[j][i] = matrix[i][j]; Example 1: Dynamic Input Matrix This example reads matrix dimensions and elements from user input − #include int main() { ...

Read More

Write a program to add two complex numbers using C

Mandalika
Mandalika
Updated on 15-Mar-2026 481 Views

In C programming, complex numbers are mathematical entities that consist of real and imaginary parts. A complex number is represented in the form a + bi, where 'a' is the real part and 'b' is the imaginary part multiplied by 'i' (the square root of -1). Syntax struct complexNumber { int real; int imaginary; }; Algorithm To add two complex numbers, we add their real parts separately and imaginary parts separately − Real part: result_real = num1_real + num2_real Imaginary part: result_imaginary = num1_imaginary ...

Read More

How to print integers in the form of Pascal triangle using C?

Mandalika
Mandalika
Updated on 15-Mar-2026 418 Views

Pascal's triangle is a triangular arrangement of integers where each number is the sum of the two numbers directly above it. This mathematical structure has many applications in combinatorics, algebra, and probability theory. Syntax // Using factorial approach int factorial(int n); int binomialCoefficient = factorial(row) / (factorial(col) * factorial(row - col)); // Using iterative approach int coefficient = 1; coefficient = coefficient * (row - col) / (col + 1); How Pascal Triangle Works Pascal's triangle follows these rules − The first and last elements of each row are ...

Read More

How to print Floyd's triangle (of integers) using C program?

Mandalika
Mandalika
Updated on 15-Mar-2026 294 Views

Floyd's triangle is a right-angle triangle of consecutive numbers, starting with 1 in the top left corner. Each row contains one more number than the previous row, forming a triangular pattern − 1 2 3 4 5 6 7 8 9 10 Syntax for (i = 1; i = 1; i--) { for (j = 1; j

Read More

Check the number is Armstrong or not using C

Mandalika
Mandalika
Updated on 15-Mar-2026 11K+ Views

An Armstrong number (also known as a narcissistic number) is a number that equals the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1³ + 5³ + 3³ = 153. Syntax number = sum of (each digit ^ number_of_digits) Algorithm To check if a number is an Armstrong number − Count the number of digits in the given number Calculate the sum of each digit raised to the power of total digits Compare this sum with the ...

Read More

Using iterative function print the given number in reverse order in C language

Mandalika
Mandalika
Updated on 15-Mar-2026 455 Views

In C programming, reversing a number means printing its digits in reverse order. This can be achieved using an iterative approach with a while loop that extracts digits from right to left and builds the reversed number. Syntax int reverse(int number) { int reversed = 0; while (number > 0) { reversed = reversed * 10 + number % 10; number = number / 10; } ...

Read More

Printing the numbers in reverse order using Division and modulo operators using C

Mandalika
Mandalika
Updated on 15-Mar-2026 1K+ Views

In C programming, we can reverse a number using division and modulo operators without using any predefined functions. This approach extracts individual digits from a number and reconstructs them in reverse order. Syntax int digit = number % 10; // Extract last digit int remaining = number / 10; // Remove last digit How It Works The logic to reverse a number using mathematical operators is − Modulo operator (%): Extracts the last digit of a number Division operator (/): Removes the last digit by integer division Extract digits ...

Read More
Showing 11–20 of 409 articles
« Prev 1 2 3 4 5 41 Next »
Advertisements