C Articles

Page 26 of 96

Explain about link and definition section in C language

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

In C programming, the link section and definition section are parts of preprocessor directives that provide instructions to the compiler before the actual compilation begins. The link section uses #include directives to include header files containing function declarations and definitions from system libraries. The definition section uses #define directives to create symbolic constants and macros. Syntax #include // Link section #define CONSTANT_NAME value // Definition section Link Section The link section tells the compiler which header files to include. This allows access to predefined functions and their ...

Read More

C program to handle integer data files using file concepts

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

In C, file handling allows us to work with different types of data including integers. This program demonstrates how to read integer data from one file and separate odd and even numbers into different files using file concepts. Syntax FILE *fopen(const char *filename, const char *mode); int putw(int w, FILE *stream); int getw(FILE *stream); int fclose(FILE *stream); Approach The program follows these steps − Create a DATA file and write integers to it Read integers from DATA file Separate odd numbers into ODD file and even numbers into EVEN file Display contents ...

Read More

Explain the pre-processor directives in C language

Aishwarya Naglot
Aishwarya Naglot
Updated on 15-Mar-2026 8K+ Views

The preprocessor is a tool that processes the source code before it passes through the compiler. It works as an initial phase of compilation where it operates under the control of different command lines or directives. Syntax #directive_name [parameters] Pre-processor Directives in C Preprocessor directives are placed in the source program before the main function, begin with the symbol "#" in column one and do not require a semicolon at the end. The commonly used preprocessor directives are − #define #undef #include #ifdef #endif #if #else The preprocessor directives ...

Read More

C program to display the prime numbers in between two intervals

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

In C programming, finding prime numbers between two intervals is a common problem that involves checking each number in the range for primality. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Syntax for(i = start + 1; i < end; i++) { flag = 0; for(j = 2; j

Read More

Find the sum of first and last digit for a number using C language

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

In C programming, finding the sum of the first and last digit of a number involves extracting these digits using modulus and division operations. The last digit is obtained using modulus 10, while the first digit is found by repeatedly dividing the number by 10. Syntax int lastDigit = number % 10; while(number > 9) { number = number / 10; } int firstDigit = number; int sum = firstDigit + lastDigit; Algorithm The algorithm to find the sum of first and last digit is as follows − ...

Read More

Explain the different sections in C language

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

A C program follows a structured format with different sections that serve specific purposes. Understanding these sections helps in writing well-organized and maintainable code. Structure of a C Program The complete C program is divided into different sections, which are as follows − Documentation Section − Contains comments about the program like author name, creation or modification date. Information written between /* */ or after // is called a comment line. These lines are ignored by the compiler during compilation. Preprocessor Directives Section − In this section, header files required to execute the program are ...

Read More

C program to display only the lower triangle elements in a 3x3 2D array

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

In a 3x3 matrix, the lower triangle consists of elements where the row index is greater than or equal to the column index (i >= j). This includes the main diagonal and all elements below it. Syntax for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { if(i >= j) // Print element at array[i][j] else ...

Read More

C program to sort an array of ten elements in an ascending order

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

An array is a group of related data items that are stored with a single name. In this article, we'll learn how to sort an array of ten elements in ascending order using the bubble sort technique. For example, int student[30]; Here, student is an array name which holds 30 collection of data items with a single variable name. Syntax for(i = 0; i < n-1; i++) { for(j = i+1; j < n; j++) { if(arr[i] > arr[j]) { ...

Read More

Explain monolithic and modular programming in C language

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

Monolithic and modular programming are two different approaches to writing C programs. The main difference lies in how the code is organized and structured. Monolithic Programming In monolithic programming, the entire program logic is written in a single function, typically the main() function. All the code is placed in one location without breaking it into smaller, manageable parts. Example: Monolithic Approach Here's an example of a monolithic program that performs arithmetic operations − #include int main() { int a = 10, b = 5; ...

Read More

How to display the complete text one word per line in C language?

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

In C, displaying text one word per line involves reading words from a file and printing each word on a separate line. This can be accomplished by using file handling functions to read words and format the output appropriately. Syntax fscanf(file_pointer, "%s", word_buffer); printf("%s", word); Example: Reading Words from File The following program demonstrates how to display text one word per line by reading from a file − Note: This example uses file operations. Create a text file named "input.txt" with some text content before running the program. #include ...

Read More
Showing 251–260 of 953 articles
« Prev 1 24 25 26 27 28 96 Next »
Advertisements