Server Side Programming Articles

Page 929 of 2109

What are character analysis function, explain with C program?

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

Character analysis functions in C are predefined functions in the ctype.h library used for analyzing and categorizing character input. These functions help determine the type of character (alphabet, digit, space, etc.) and convert between uppercase and lowercase letters. Syntax #include int isalpha(int c); int isdigit(int c); int isupper(int c); int islower(int c); int toupper(int c); int tolower(int c); Character Analysis Functions S.No Function Description 1 isalpha() Checks if character is an alphabet (a-z, A-Z) 2 isdigit() Checks if character is a digit (0-9) ...

Read More

Working with two-dimensional array at runtime in C programming

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

In C programming, working with two-dimensional arrays at runtime involves dynamically allocating memory and performing operations on the array elements. This approach allows for flexible array sizes determined during program execution. Syntax // Static array declaration int array[rows][cols]; // Dynamic allocation for 2D arrays int **array = (int**)malloc(rows * sizeof(int*)); for(int i = 0; i < rows; i++) { array[i] = (int*)malloc(cols * sizeof(int)); } Problem Write a C program to calculate sum and product of all elements in two-dimensional arrays using runtime operations. Solution Runtime ...

Read More

Finding even and odd numbers in a set of elements dynamically using C language

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

In C programming, we can find and calculate the sum of even and odd numbers from a set of elements using dynamic memory allocation. This approach allows us to handle variable-sized datasets efficiently by allocating memory at runtime. Syntax ptr = (int *)malloc(n * sizeof(int)); if (ptr == NULL) { // Handle memory allocation failure } // Use the allocated memory free(ptr); Algorithm The logic to separate even and odd numbers is straightforward − Even numbers: Numbers divisible by 2 (remainder is 0 when divided by 2) Odd ...

Read More

Explain dynamic memory allocation in C with an example

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

Dynamic memory allocation in C allows programmers to allocate and deallocate memory during program execution rather than at compile time. This provides flexibility to handle varying data sizes efficiently. Syntax void* malloc(size_t size); void* calloc(size_t num, size_t size); void* realloc(void* ptr, size_t new_size); void free(void* ptr); Dynamic Memory Allocation Functions The main functions used for dynamic memory allocation in C are − malloc() − allocates a block of memory in bytes at runtime calloc() − allocates continuous blocks of memory and initializes them to zero realloc() − used to resize previously allocated ...

Read More

Post and Pre incremented of arrays in C language

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

In C programming, pre and post increment operators can be applied to array elements to modify their values. Understanding how these operators work with arrays is crucial for effective C programming. Syntax // Pre-increment: increment first, then use value variable = ++array[index]; // Post-increment: use value first, then increment variable = array[index]++; Pre-increment vs Post-increment Increment operator (++) − It is used to increment the value of a variable by 1 There are two types of increment operators − pre increment and post increment Pre-increment (++variable): Increment operator is placed before ...

Read More

Matrix row sum and column sum using C program

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

In C programming, calculating the sum of rows and columns in a matrix is a fundamental operation. This involves iterating through each row to compute row sums and through each column to compute column sums using nested loops. Syntax for(i=0; i

Read More

How to print the numbers in different formats using C program?

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

In C programming, we can print numbers and symbols in different patterns like pyramids and triangles using nested loops. The outer loop controls the rows while inner loops handle spacing and pattern generation. Syntax for(int i = 1; i

Read More

Explain Compile time and Run time initialization in C programming?

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

In C programming, array initialization can occur at two different times: compile time and run time. Understanding the difference between these two approaches is crucial for effective memory management and program design. Syntax // Compile time initialization type array_name[size] = {value1, value2, ..., valueN}; // Run time initialization type array_name[size]; // Values assigned during program execution Compile Time Initialization In compile time initialization, array values are specified directly in the source code when the array is declared. The compiler allocates memory and assigns values during the compilation process − #include ...

Read More

Why is the compiler not reading string after integer in C programming?

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

When reading string input after integer input in C, a common issue occurs where the string appears to be skipped. This happens because scanf() leaves a newline character in the input buffer after reading the integer. The Problem When you use scanf() to read an integer and then try to read a string using gets() or fgets(), the leftover newline character from the integer input is immediately consumed by the string function, causing it to terminate without reading actual string input. Solution Methods Method 1: Using a Temporary Character Read the leftover newline character using ...

Read More

What is the common error occurred while using scanf() statement in C language?

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

The scanf() function in C is commonly used to read formatted input, but it often causes issues when reading strings after numeric values. The main problem occurs because scanf() leaves a newline character in the input buffer after reading numbers, which interferes with subsequent string input functions. Common Error When using scanf() to read numeric data followed by string input with gets() or fgets(), the string input is skipped because the leftover newline character from the previous scanf() is immediately consumed. Example: Demonstrating the Problem Here's a program that shows the common error when reading a ...

Read More
Showing 9281–9290 of 21,090 articles
« Prev 1 927 928 929 930 931 2109 Next »
Advertisements