C Articles

Page 8 of 96

C program to convert decimal fraction to binary fraction

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

Converting decimal fractions to binary involves two separate processes: converting the integer part and the fractional part. The integer part uses division by 2, while the fractional part uses multiplication by 2. Syntax // For integer part: repeatedly divide by 2, collect remainders // For fractional part: repeatedly multiply by 2, collect integer parts Algorithm For Integer Part (25) − Step 1 − 25 / 2 Rem: 1, Quo: 12 Step 2 − 12 / 2 Rem: 0, Quo: 6 Step 3 − 6 / 2 Rem: 0, Quo: 3 Step 4 ...

Read More

C program to compute the polynomial regression algorithm

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

Polynomial regression is a form of regression analysis used to model the relationship between an independent variable x and dependent variable y as an nth degree polynomial. This technique extends linear regression to capture non-linear relationships in data. Syntax y = a0 + a1*x + a2*x² + a3*x³ + ... + an*xⁿ Where a0, a1, a2, ..., an are coefficients to be determined using least squares method. Algorithm The polynomial regression algorithm works by − Setting up a system of normal equations using least squares method Creating coefficient matrix from input ...

Read More

C program to compute linear regression

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

Linear regression is a statistical method used to find the relationship between two variables by fitting a linear equation to observed data. In C programming, we can implement linear regression to find the slope (m) and y-intercept (c) of the line that best fits the data points. Syntax y = mx + c where: m = (n*Σ(xy) - Σ(x)*Σ(y)) / (n*Σ(x²) - (Σ(x))²) c = (Σ(y)*Σ(x²) - Σ(x)*Σ(xy)) / (n*Σ(x²) - (Σ(x))²) Linear Regression Formula The linear regression algorithm uses the least squares method to calculate the slope (m) and intercept (c) − ...

Read More

C program to convert roman numbers to decimal numbers

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

Roman numerals are a numeral system that originated in ancient Rome and remained the usual way of writing numbers throughout Europe. In C programming, converting roman numbers to decimal requires understanding the basic roman symbols and their subtraction rule. Roman Numeral System The basic roman numerals and their decimal values are − Roman Decimal Roman Decimal I 1 L 50 V 5 C ...

Read More

C program to compute geometric progression

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

In C programming, a geometric progression (GP) is a sequence where each term after the first is found by multiplying the previous term by a common ratio. The sum of a geometric progression follows the formula: 1 + x + x² + x³ + ... + xⁿ. Syntax sum = 1 + x + x² + x³ + ... + xⁿ Algorithm The algorithm to compute geometric progression is as follows − Read values for x (common ratio) and n (number of terms) Initialize sum to 0 Use a loop to calculate ...

Read More

C Program to delete n characters in a given string

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

In C programming, deleting n characters from a specific position in a string involves shifting the remaining characters to fill the gap. This operation modifies the original string by removing a substring starting from a given position. Syntax void deleteString(char str[], int position, int n); Algorithm The algorithm to delete n characters from a given position in a string is as follows − Step 1 − Read the input string Step 2 − Read the starting position for deletion Step 3 − Read the number of characters to delete Step 4 − ...

Read More

C program to find GCD of numbers using recursive function

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

The greatest common divisor (GCD) of two numbers is the largest positive integer that divides both numbers evenly. In C programming, we can find the GCD using the Euclidean algorithm implemented with a recursive function. Syntax unsigned int GCD(unsigned i, unsigned j); Algorithm The recursive GCD algorithm follows these steps − Step 1 − Define the recursive function. Step 2 − Read the two integers a and b. Step 3 − Call recursive function with the following logic: a. if j > i then return GCD(j, i) b. if ...

Read More

C program to calculate sum of series using predefined function

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

In C programming, calculating the sum of mathematical series is a common task. This program demonstrates how to calculate the sum of the series: 1 - n²/2! + n⁴/4! - n⁶/6! + n⁸/8! - n¹⁰/10! using the predefined pow() function from the math.h library. Syntax double pow(double base, double exponent); Algorithm The algorithm to calculate the sum of series using predefined function − Step 1: Read the value of n from user Step 2: Initialize factorial = 1, sum = 1, and loop counter Step 3: For each even power from 2 ...

Read More

C program to count characters, lines and number of words in a file

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

In C programming, counting characters, words, and lines in a file is a common file processing task. This operation reads through a file character by character and keeps track of different elements based on specific delimiters. Syntax FILE *fopen(const char *filename, const char *mode); int fgetc(FILE *stream); int fclose(FILE *stream); File Operations Overview The three basic operations that we can perform on files are − Open a file − Using fopen() function Process file − Read, write, or modify file contents Save and close file − Using fclose() function Example: ...

Read More

C program to remove a line from the file

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

In C, removing a line from a file requires creating a temporary file because files cannot be modified directly in place. The process involves reading the original file line by line, copying all lines except the target line to a temporary file, then replacing the original file. Syntax FILE *fopen(const char *filename, const char *mode); char *fgets(char *str, int n, FILE *stream); int fputs(const char *str, FILE *stream); int remove(const char *filename); int rename(const char *oldname, const char *newname); Algorithm The algorithm to remove a line from a file follows these steps − ...

Read More
Showing 71–80 of 953 articles
« Prev 1 6 7 8 9 10 96 Next »
Advertisements