Programming Articles

Page 927 of 2547

C Program find nCr and nPr.

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 18K+ Views

In C programming language, nCr is referred as the combination. nCr is the selection of r objects from a set of n objects, where the order of objects does not matter. nPr is referred as the permutation. nPr is arrangement of 'r' objects from a set of 'n' objects, which should be in an order or sequence. Syntax nCr = n! / (r! * (n-r)!) nPr = n! / (n-r)! Permutations and Combinations Formulas The formulas to find the permutation and combination of given numbers in C language are given below − ...

Read More

C program to perform intersection operation on two arrays

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 9K+ Views

In C programming, an array intersection operation finds all common elements between two arrays. The intersection of two arrays contains only the elements that appear in both arrays, without duplicates. Syntax for(i=0; i

Read More

C program to perform union operation on two arrays

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 15K+ Views

The union operation on arrays combines all elements from both arrays while eliminating duplicates. This is similar to the mathematical set union operation, where each element appears only once in the result. Syntax int unionArrays(int arr1[], int size1, int arr2[], int size2, int result[]); Union Operation Example Given two arrays: Array 1 = {1, 2, 3, 4, 6} Array 2 = {1, 2, 5, 6, 7} The union operation produces: Array1 ∪ Array2 = {1, 2, 3, 4, 5, 6, 7} Array 1 ...

Read More

What is a simple assertion in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 359 Views

An assertion is a statement used to declare positively that a fact must be true when that line of code is reached. Assertions are debugging tools that help catch programming errors during development by validating expected conditions. Syntax assert(expression); Where expression is a condition that should evaluate to true. The assert() macro is defined in the assert.h header file. How Assertions Work True condition: When the expression is true, the program continues normally with no action. False condition: When the expression is false, the program terminates and displays an error message with ...

Read More

C Program to find sum of perfect square elements in an array using pointers.

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, finding the sum of perfect square elements in an array using pointers involves traversing the array with pointer arithmetic and checking if each element is a perfect square. A perfect square is a number that can be expressed as the product of an integer with itself (e.g., 1, 4, 9, 16, 25). Syntax int isPerfectSquare(int num); int sumPerfectSquares(int *arr, int size); Algorithm Step 1 − Read the number of elements in the array. Step 2 − Input the array elements. Step 3 − Initialize sum = 0 and declare a pointer ...

Read More

C program to represent the numbers in spiral pattern

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, a spiral pattern displays numbers in alternating left-to-right and right-to-left order across rows. This creates a visual spiral effect where consecutive pairs of numbers appear in different orders on each row. Spiral Pattern 1 2 4 3 5 6 8 7 Blue: Left to Right Red: Right to Left Pattern alternates every row Syntax for(i=1; i

Read More

C program to find type of array entered by the user.

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 1K+ Views

In C programming, we can classify an array based on the type of numbers it contains. An array can be classified as an even array (all elements are even), an odd array (all elements are odd), or a mixed array (contains both even and odd elements). Algorithm Here's the approach to determine the array type − Read the array size and elements from user Count even and odd numbers in separate counters Compare counters with total size to determine array type Display the result based on the comparison Example The following program demonstrates ...

Read More

C Program to display the numbers in X pattern

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, displaying numbers in an X pattern is a common pattern printing exercise. The X pattern consists of numbers arranged such that they appear on the main diagonal (top-left to bottom-right) and anti-diagonal (top-right to bottom-left) of a square grid. Syntax for(i = 0; i < rows; i++) { for(j = 0; j < rows; j++) { if(i == j || i + j == rows - 1) { printf("%d", i ...

Read More

C program for testing the character type

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 1K+ Views

In C programming, the ctype.h library provides predefined functions for analyzing and converting character types. These functions are essential for validating user input and performing character-based operations. Syntax #include int isalpha(int c); int isdigit(int c); int isspace(int c); int ispunct(int c); int islower(int c); int isupper(int c); int isalnum(int c); int tolower(int c); int toupper(int c); Analysis Functions The character analysis functions are listed below − Function Checks whether entered character is isalpha An alphabet or not isdigit A digit or not ...

Read More

C program to convert days into months and number of days

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 14K+ Views

In C programming, we can convert a total number of days into months and remaining days using simple arithmetic operations. This conversion assumes each month has 30 days on average. Syntax months = total_days / 30; remaining_days = total_days % 30; Algorithm The algorithm to convert days into months and remaining days is as follows − Step 1: Start Step 2: Declare variables for months, days, and total_days Step 3: Read total number of days from user Step 4: Calculate months using division months ...

Read More
Showing 9261–9270 of 25,466 articles
« Prev 1 925 926 927 928 929 2547 Next »
Advertisements