Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 958 of 2547
Program to print pentatope numbers upto Nth term in C
A pentatope number is a figurate number that represents the number of points in a pentatope (4-dimensional simplex). These numbers form the fifth diagonal of Pascal's triangle. The nth pentatope number represents the number of ways to choose 4 items from n+3 items. Syntax pentatope(n) = n * (n + 1) * (n + 2) * (n + 3) / 24 Mathematical Formula The formula for the nth pentatope number is − pentatope(n) = C(n+3, 4) = n * (n + 1) * (n + 2) * (n + 3) / 24 ...
Read MoreProgram to print numbers columns wise in C
In C programming, we can create patterns where natural numbers are arranged column-wise in a triangular format. This pattern displays numbers in columns, where each row contains one more number than the previous row. Pattern Description The pattern arranges numbers as follows − 1 2 6 3 7 10 4 8 11 13 5 9 12 14 15 Each number is placed based on its column position, creating a triangular arrangement where numbers flow vertically in columns. Algorithm The algorithm uses the following approach − i represents the current row ...
Read MoreProgram to print number pattern in C
Numerical patterns in C programming involve printing sequences of numbers arranged in specific shapes or structures. These patterns follow mathematical rules and are excellent for practicing nested loops and logical thinking. Syntax for(i = start; condition; increment/decrement) { for(j = start; condition; increment/decrement) { printf("format", value); } printf(""); } Example 1: Triangular Number Pattern This pattern displays numbers in a triangular format where each row contains specific values based on a mathematical formula − #include int main() { int i, j, k; printf("Triangular Number Pattern:"); for(i = 1; i
Read MorePrint the Non Square Numbers in C
In C programming, a perfect square is an integer that is the square of another integer. For example, 1, 4, 9, 16, 25 are perfect squares because they equal 1², 2², 3², 4², 5² respectively. Non-square numbers are all other positive integers that are not perfect squares. Syntax #include int sqrt(double x); // Returns square root of x Perfect Square Numbers The first few perfect squares are − 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 These correspond to − 1² = 1, 2² ...
Read MoreProgram to Print Mirrored Hollow Parallelogram in C
A mirrored hollow parallelogram is a pattern where a hollow parallelogram shape is printed with leading spaces to create a mirrored or slanted effect. The pattern consists of stars forming the outline while the interior remains hollow. Syntax for(r = 1; r
Read MorePrint the Mirror Image of Sine-Wave Pattern in C
In C programming, creating a mirror image of a sine-wave pattern involves printing a visual representation where waves appear to be reflected. This pattern uses the mathematical concept of symmetry to create wave-like shapes using characters. Syntax for(i = 1; i
Read MoreProgram to Print the Squared Matrix in Z form in C
In C programming, printing a squared matrix in Z form means displaying the elements in a specific pattern − first the top row, then the diagonal elements from top-right to bottom-left, and finally the bottom row. This creates a Z-shaped traversal pattern through the matrix. Syntax /* Z-form traversal pattern */ // First row: matrix[0][0] to matrix[0][n-1] // Diagonal: matrix[i][n-1-i] where i goes from 1 to n-2 // Last row: matrix[n-1][1] to matrix[n-1][n-1] Algorithm 1 2 3 ...
Read MoreProgram to print Lower triangular and Upper triangular matrix of an array in C
In C, triangular matrices are special square matrices where elements are zero either above or below the main diagonal. This program demonstrates how to print both lower and upper triangular matrices from a given matrix. Syntax /* Lower Triangular: matrix[i][j] = 0 when j > i */ /* Upper Triangular: matrix[i][j] = 0 when i > j */ Triangular Matrix Types Lower Triangular Matrix − A square matrix where all entries above the main diagonal are zero. Lower Triangular ...
Read MoreWhy is a[i] == i[a] in C/C++ arrays?
In C programming, there's an interesting feature where array subscript notation a[i] can also be written as i[a]. This happens because of how C internally handles array indexing through pointer arithmetic. Syntax a[i] == i[a] // Both expressions are equivalent How It Works In C, E1[E2] is defined as (*((E1) + (E2))). The compiler performs pointer arithmetic internally to access array elements. Because the binary + operator is commutative, a[i] becomes *(a + i), and i[a] becomes *(i + a). Since addition is commutative, both expressions evaluate to the same memory ...
Read MoreHow to sort an array of dates in C/C++?
In C programming, sorting an array of dates requires creating a structure to represent dates and implementing a custom comparison function. We use the qsort() function from the standard library to sort the array based on chronological order. Syntax void qsort(void *base, size_t num, size_t size, int (*compare)(const void *, const void *)); Method 1: Using qsort() with Custom Comparator This approach uses a structure to store date components and a comparison function that compares dates chronologically − #include ...
Read More