Bhanu Priya

Bhanu Priya

1,061 Articles Published

Articles by Bhanu Priya

Page 44 of 107

Explain append mode operation of files in C language

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

In C programming, append mode is a file opening mode that allows you to add new data to the end of an existing file without overwriting its current contents. When you open a file in append mode, the file pointer is automatically positioned at the end of the file. Syntax FILE *fp; fp = fopen("filename.txt", "a"); Where "a" represents the append mode. If the file doesn't exist, a new file will be created. If the file exists, new data will be added after the existing content. Key Features of Append Mode File ...

Read More

Explain read mode operation of files in C language

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

In C programming, file handling allows us to perform various operations on files stored on disk. The read mode operation is one of the fundamental file operations that enables us to access and retrieve data from existing files. Syntax FILE *file_pointer; file_pointer = fopen("filename", "r"); File Declaration and Opening in Read Mode To work with files in C, we first need to declare a file pointer and then open the file in read mode − FILE *fp; fp = fopen("filename.txt", "r"); The fopen() function returns a pointer to the file ...

Read More

Explain write mode operation of files in C language

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

File write mode in C is used to open a file for writing data. When a file is opened in write mode, you can store data permanently in the file, which persists even after the program terminates. Need of Files Entire data is lost when a program terminates. Storing in a file preserves the data even if the program terminates. If you want to enter a large amount of data, normally it takes a lot of time to enter them all. We can easily access the content of files by using few commands. You can easily move ...

Read More

How to separate even and odd numbers in an array by using for loop in C language?

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

In C programming, separating even and odd numbers from an array is a common operation that involves checking each element's divisibility by 2. This process uses the modulus operator (%) to determine if a number leaves a remainder when divided by 2. Syntax // Check if number is even if (number % 2 == 0) { // number is even } // Check if number is odd if (number % 2 != 0) { // number is odd } Algorithm The logic to ...

Read More

How to perform the arithmetic operations on arrays in C language?

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

In C programming, arrays allow us to store multiple related data items under a single name. We can perform arithmetic operations like addition, subtraction, multiplication, division, and modulus on corresponding elements of two arrays. For example, int student[30]; declares an array named student that can hold 30 integer values. Array Operations Searching − Finding whether a particular element is present in the array Sorting − Arranging elements in ascending or descending order Traversing − Processing every element sequentially Inserting − Adding new elements to the array Deleting − Removing elements from the array Syntax ...

Read More

C program to replace all occurrence of a character in a string

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

In C programming, replacing characters in a string is a common string manipulation task. This involves searching for a specific character and replacing it with another character either for all occurrences or just the first occurrence. Syntax for(i = 0; string[i] != '\0'; i++) { if(string[i] == old_char) { string[i] = new_char; } } Method 1: Replace All Occurrences This method replaces every occurrence of a character in the string − #include #include ...

Read More

How to find the product of given digits by using for loop in C language?

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

In C programming, finding the product of digits involves extracting each digit from a number and multiplying them together. This is commonly done using loops to repeatedly divide the number by 10 and extract the remainder. Syntax for(product = 1; num > 0; num = num / 10) { rem = num % 10; product = product * rem; } Method 1: Using For Loop The for loop approach initializes the product to 1 and continues until all digits are processed − #include ...

Read More

How to swap two arrays without using temporary variable in C language?

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

In C programming, swapping two arrays without using a temporary variable can be achieved using arithmetic or bitwise operations. This technique exchanges the contents of two arrays by manipulating the values directly, avoiding the need for additional memory space. Syntax for(i = 0; i < size; i++) { array1[i] = array1[i] + array2[i]; array2[i] = array1[i] - array2[i]; array1[i] = array1[i] - array2[i]; } Method 1: Using Arithmetic Operations This method uses addition and subtraction to swap array elements − ...

Read More

C program to find palindrome number by using while loop

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

A palindrome number is a number which remains the same when its digits are reversed. For example, 121, 1331, and 7557 are palindrome numbers. In C programming, we can check if a given number is a palindrome by using a while loop to reverse the number and then comparing it with the original. Syntax while (condition) { // Extract last digit remainder = number % 10; // Build reversed number reversed = reversed * 10 + remainder; ...

Read More

C program to convert centimeter to meter and kilometer

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

In C programming, converting between different units of length is a common task. This program demonstrates how to convert centimeters to meters and kilometers using simple mathematical formulas. Conversion Formulas 1 Meter = 100 Centimeters 1 Kilometer = 100000 Centimeters Syntax meter = centimeter / 100.0; kilometer = centimeter / 100000.0; Algorithm The algorithm to convert centimeter into meter and kilometer is as follows − Step 1: Declare variables for centimeter, meter, and kilometer. Step 2: Read length in centimeters from user input. Step 3: Convert to meters ...

Read More
Showing 431–440 of 1,061 articles
« Prev 1 42 43 44 45 46 107 Next »
Advertisements