C Articles

Page 13 of 96

Write a C program to print all files and folders.

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

In C programming, we can list all files and folders in a directory using directory handling functions. This requires the dirent.h header which provides structures and functions to work with directory entries. Syntax DIR *opendir(const char *dirname); struct dirent *readdir(DIR *dirp); int closedir(DIR *dirp); Key Functions opendir() − Opens a directory stream for reading readdir() − Reads directory entries one by one closedir() − Closes the directory stream Note: This program uses dirent.h which is POSIX standard. On Windows with certain compilers, you might need additional setup or use platform-specific ...

Read More

Explain the quick sort technique in C language.

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

Quick sort is a highly efficient divide-and-conquer sorting algorithm that works by selecting a 'pivot' element and partitioning the array around it. Elements smaller than the pivot go to the left, and larger elements go to the right, then the process is repeated recursively on both subarrays. How Quick Sort Works The quick sort algorithm follows these steps − Step 1: Choose a pivot element from the array (typically the first, last, or middle element) Step 2: Partition the array so elements less than pivot are on the ...

Read More

C program to print the ASCII values in a string.

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

In C programming, we can print the ASCII values of characters in a string by iterating through each character and using the %d format specifier to display its numeric ASCII value. Syntax while(str[i] != '\0') { printf("ASCII Value of %c = %d", str[i], str[i]); i++; } String Declaration and Initialization A string in C is an array of characters terminated by a null character '\0'. Declaration: char stringname[size]; Initialization methods: Using character constants: char string[10] = ...

Read More

C Program to print all ASCII values.

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

ASCII (American Standard Code for Information Interchange) is a character encoding standard that assigns numeric values to characters. In C programming, we can print ASCII values of characters using format specifiers without explicitly converting characters to integers. Syntax printf("%c \t %d", i, i); Method 1: Printing ASCII Values from A to z (65 to 122) This example prints ASCII values for uppercase letters, special characters, and lowercase letters − #include int main() { int i; printf("Character \t ASCII Value"); // Print ASCII values from A to z for (i = 65; i = 32 && i

Read More

C program to remove spaces in a sentence using string concepts.

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

In C, removing spaces from a string involves iterating through the string and eliminating space characters. This can be accomplished using string manipulation techniques where we shift characters to overwrite spaces. Syntax while(string[i] != '\0') { if(string[i] == ' ') { // Shift characters left to remove space } i++; } String Declaration and Initialization An array of characters is called a string. Given below is the declaration of a string − ...

Read More

Deletion of head and tail element logic in a linked list using C language.

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

In C programming, deleting head and tail elements from a linked list are fundamental operations that require careful pointer manipulation to maintain list integrity. A linked list is a dynamic data structure where each node contains data and a pointer to the next node. Syntax // Delete head node void deleteHead(); // Delete tail node void deleteTail(); Node Structure First, let's define the basic node structure for our linked list − Data Next Node Structure ...

Read More

Explain the pointers for inter-function communication in C language.

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

Pointers enable inter-function communication in C by allowing functions to modify variables in the calling function's scope. This is essential for pass-by-reference behavior and returning multiple values from a single function. Syntax // Function declaration with pointer parameters return_type function_name(data_type *pointer_param); // Function call passing address function_name(&variable); Key Concepts Pass-by-value: Function receives a copy of the variable's value Pass-by-reference: Function receives the address of the variable using pointers Multiple return values: Use pointers to modify multiple variables in the calling function Example: Returning Multiple Values The following program demonstrates ...

Read More

Explain scope of a variable in C language.

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

In C programming, the scope of a variable defines where in the program that variable can be accessed or referenced. Variable scope determines the visibility and accessibility of variables throughout different parts of your program. Syntax // Global scope data_type variable_name; int main() { // Local scope data_type variable_name; return 0; } Types of Variable Scope C language supports two main types of variable scope − Local Scope: Variables declared inside a function or block are only accessible within ...

Read More

C program for Addition and Multiplication by 2 using Bitwise Operations.

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

Bitwise operators in C operate directly on bits (binary representation) of operands. They are highly efficient for arithmetic operations like multiplication and division by powers of 2. The left shift () operators can perform these operations faster than traditional arithmetic operators. Syntax // Multiplication by 2 result = number > 1; Bitwise Operators Overview Operator ...

Read More

C program to print area of triangle, square, circle, rectangle and polygon using switch case.

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

This C program calculates the area of different geometric shapes using a switch case statement. The program provides a menu−driven interface where users can select from triangle, square, circle, rectangle, and parallelogram area calculations. Syntax switch (expression) { case constant1: // statements break; case constant2: // statements break; default: ...

Read More
Showing 121–130 of 953 articles
« Prev 1 11 12 13 14 15 96 Next »
Advertisements