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
Server Side Programming Articles
Page 933 of 2109
Program to check if a string contains any special character in C
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 MoreProduct of N with its largest odd digit in C
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 MoreProduct of maximum in first array and minimum in second in C
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 MoreBitwise recursive addition of two integers in C
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 MoreC Programming Language Standard
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 MoreC program to store Student records as Structures and Sort them by Name
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 MoreMaximum number of threads that can be created within a process in C
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 MoreCount minimum bits to flip such that XOR of A and B equal to C in C++
We are given three binary sequences A, B and C of length N. Each sequence represents a binary number. We have to find the number of bit flips required in A and B such that XOR of A and B results in C. Syntax int flipCount(int A[], int B[], int C[], int n); First, let us understand the XOR operation truth table − X ...
Read MoreFind a permutation that causes worst case of Merge Sort in C
Merge sort has a consistent O(n log n) time complexity, but in practice, certain input permutations require more comparisons during the merge operations. The worst case occurs when the merge operation at each level compares every element from both subarrays before completing. Syntax void generateWorstCase(int arr[], int left, int right); Understanding the Worst Case The worst case for merge sort happens when at each merge operation, elements from left and right subarrays are alternately selected. This forces maximum comparisons since we cannot skip any elements during merging. Algorithm To generate the worst ...
Read Morefillpoly() function in C
The fillpoly() function in C is part of the graphics.h library and is used to draw and fill a polygon with the current fill pattern and color. It takes the same arguments as drawpoly() but additionally fills the interior of the polygon. Syntax void fillpoly(int numpoints, int *polypoints); Parameters numpoints − Specifies the number of points in the polygon polypoints − Pointer to an array containing x, y coordinates of each point The polypoints array should contain numpoints * 2 integers, where each pair represents the x and y coordinates of ...
Read More