Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 925 of 2547
What are different variations of for loop iterations?
The for loop in C offers several variations beyond its standard form, making it a versatile control structure. Each variation serves specific programming needs, from multiple variable initialization to infinite loops. Syntax for (initialization; condition; increment/decrement) { // statements } The basic components are − Initialization − Sets the initial value of loop control variable(s) Condition − Tests whether to continue the loop execution Operation − Updates the loop variable after each iteration Variation 1: Multiple Variable Initialization The comma operator allows initializing multiple variables in ...
Read MoreWhat is exit() function in C language?
The exit() function in C is used to terminate a program immediately. This function causes the program to stop execution and return control to the operating system. Unlike a normal return from main(), exit() can be called from anywhere in the program. Syntax void exit(int status); Parameters status − An integer value returned to the operating system. Conventionally, 0 indicates successful termination, and non-zero values indicate errors. Return Value The exit() function does not return any value as it terminates the program immediately. Note: To use the exit() ...
Read MoreC program to print four powers of numbers 1 to 9 using nested for loop
In C programming, nested loops are powerful constructs where one loop is placed inside another loop. This technique is particularly useful for creating tables, matrices, and complex patterns. Here we'll use nested for loops to generate a table showing the first four powers of numbers 1 to 9. Syntax for (initialization; condition; increment) { for (initialization; condition; increment) { // Inner loop statements } // Outer loop statements } How Nested Loops Work In ...
Read MoreWhat are reading and writing characters in C language?
In C programming language, reading and writing characters are fundamental I/O operations that allow programs to interact with users through the console. Syntax int getchar(void); int putchar(int c); Character Input/Output Functions C provides several functions for character I/O operations − getchar() − Reads a character from standard input (keyboard) putchar() − Writes a character to standard output (screen) getche() − Reads a character with echo (non-standard, conio.h) getch() − Reads a character without echo (non-standard, conio.h) Example: Basic Character Reading and Writing This example demonstrates reading characters and converting ...
Read MoreWhat are printf conversion characters and their types?
In C programming, printf() conversion characters (also called format specifiers) are special codes that tell printf() how to format and display different data types. These characters are preceded by a % symbol and specify the type and format of the variable to be printed. Syntax printf("format string with %specifier", variable); Common Printf Conversion Characters Here is a list of the most commonly used conversion characters in printf() − %d − signed decimal integer %u − unsigned decimal integer %x − hexadecimal integer (lowercase) %X − hexadecimal integer (uppercase) %o − octal integer ...
Read MoreC program to convert decimal fraction to binary fraction
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 MoreC program to compute the polynomial regression algorithm
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 MoreC program to compute linear regression
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 MoreC program to convert roman numbers to decimal numbers
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 MoreC program to compute geometric progression
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