C Articles

Page 34 of 96

Product of middle row and column in an odd square matrix in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 306 Views

Given a square matrix, mat[row][column] where row and column are equal and are of odd length, the task is to find the product of middle row and middle column of that matrix. The matrix must have odd dimensions so there's always a clear middle row and column. 1 2 3 4 5 ...

Read More

Program to compare two fractions in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 792 Views

In C programming, comparing two fractions requires cross-multiplication to avoid floating-point precision issues. Given two fractions with numerators and denominators, we need to determine which fraction has the greater value. Syntax struct Fraction { int nume, deno; }; struct Fraction greater(struct Fraction first, struct Fraction second); Approach To compare fractions a/b and c/d, we use cross-multiplication: if a*d > b*c, then a/b > c/d. This avoids floating-point division and maintains precision. Example 1: Basic Fraction Comparison This example compares 4/5 and 3/4 using cross-multiplication − ...

Read More

Program to check if an array is sorted or not (Iterative and Recursive) in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 4K+ Views

Given an array arr[] with n number of elements, our task is to check whether the given array is in sorted order or not. If it is in sorted order then print "The array is in sorted order", else print "The array is not in sorted order". To solve this problem we can use iterative or recursive approach, we will be discussing both. Syntax int isSorted(int arr[], int n); Method 1: Iterative Approach In iterative approach, we use loops to traverse the array and compare adjacent elements ? #include ...

Read More

Program to check if a string contains any special character in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 7K+ Views

In C programming, checking if a string contains special characters is a common validation task. Special characters are those that are neither alphabetic nor numeric, such as symbols like !@#$%^&*() etc. Syntax int checkSpecialCharacter(char str[], int length); Method 1: Using Character Comparison This method iterates through each character and compares it against a predefined set of special characters − #include #include int checkSpecialCharacter(char str[], int n) { int i; for (i = 0; i < n; i++) { ...

Read More

Product of N with its largest odd digit in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 482 Views

In C programming, we need to find the product of a given number N with its largest odd digit. If the number contains no odd digits, we return -1. Syntax int largestOddDigit(int n); int findProduct(int n); Algorithm Extract each digit of the number using modulo operation Check if the digit is odd and compare with the current largest odd digit Keep track of the maximum odd digit found Multiply the original number with the largest odd digit Return -1 if no odd digit exists Example 1: Number with Odd Digits ...

Read More

Product of maximum in first array and minimum in second in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 380 Views

Given two arrays, we need to find the product of the maximum element from the first array and the minimum element from the second array. This is a common programming problem that demonstrates array traversal and basic mathematical operations. Syntax int findMaxElement(int arr[], int size); int findMinElement(int arr[], int size); int calculateProduct(int arr1[], int arr2[], int n1, int n2); Method 1: Using Sorting Approach In this approach, we sort both arrays and then multiply the last element of the first array with the first element of the second array − #include ...

Read More

Bitwise recursive addition of two integers in C

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 4K+ Views

In this problem, we are given two numbers. Our task is to create a C program for the bitwise recursive addition of two integers. The logic to find the sum using bitwise operations is similar to manual addition we learned in school. For finding the sum, we add each digit and if a carry is generated, we add it to the next digit position. We will use the XOR operator to find the sum and the AND operation to check for carry. If there is a carry, we recursively add it back to the result. This is the ...

Read More

C Programming Language Standard

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn about the standards defined in the C programming language. These standards specify how programs should be compiled and executed as defined by the development community. To understand this concept, let's examine a common C program that demonstrates standard compliance issues − What is the C Programming Language Standard? The C programming language standard defines the official specification for how C compilers should behave. It establishes the correct syntax, semantics, and behavior of C programs. The latest C standard is ISO/IEC 9899:2018, also known as C18, which was released in June 2018. ...

Read More

C program to store Student records as Structures and Sort them by Name

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 2K+ Views

In this problem, we are given a student's record which contains student_id, student_name, and student_percentage. Our task is to create a C program to store student records as structures and sort them by name using string comparison. Syntax struct Student { int student_id; char student_name[50]; int student_percentage; }; int qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)); Example Input and Output Input − student record − { student_id = 1, student_name = Nupur, student_percentage = ...

Read More

Maximum number of threads that can be created within a process in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 1K+ Views

In this article, we will explore how to determine the maximum number of threads that can be created within a process in C. Understanding thread limits is crucial for developing efficient multi-threaded applications. A thread is a lightweight process that can be independently managed by the scheduler. Multiple threads can be associated with a single process, and they require less time for context switching compared to processes. Threads share memory with their peer threads and require fewer resources for creation and termination. Syntax int pthread_create(pthread_t *thread, const pthread_attr_t *attr, ...

Read More
Showing 331–340 of 953 articles
« Prev 1 32 33 34 35 36 96 Next »
Advertisements