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 1018 of 2547
Difference between %d and %i format specifier in C
In C programming, both %d and %i are format specifiers used for integer values, but they behave differently when used with scanf() for input operations. For printf(), they work identically. Syntax printf("%d", integer_variable); // Decimal output printf("%i", integer_variable); // Integer output (same as %d for printf) scanf("%d", &integer_variable); // Reads decimal integers only scanf("%i", &integer_variable); // Reads decimal, octal, and hexadecimal Format Specifier %d The %d format specifier handles signed decimal integers. For printf(), it displays integers in decimal form. For scanf(), it only accepts decimal ...
Read MorePHP – How to subtract one arbitrary precision number from another using bcsub() function?
In PHP, bcsub() math function is used to subtract one arbitrary precision number from another number. The bcsub() function takes two arbitrary precision numbers as strings and returns the subtraction result after scaling to a specified precision. Syntax string bcsub($num_str1, $num_str2, $scaleVal) Parameters The bcsub() math function accepts three different parameters $num_str1, $num_str2 and $scaleVal. $num_str1 − It represents the left operand and it is the string type parameter. ...
Read MoreFloat and Double in C
In C programming, float and double are data types used to represent floating point numbers. Both follow the IEEE 754 standard but differ in precision and memory usage. Float Data Type Float is a 32-bit IEEE 754 single precision floating point number with the following structure − 1 bit for the sign 8 bits for the exponent 23 bits for the mantissa (fractional part) Precision: 6-7 decimal digits Syntax float variable_name; Example: Float Declaration and Usage #include int main() { float x ...
Read MorePHP – How to compare two arbitrary precision numbers using bccomp() function?
In PHP, the bccomp() function is used to compare two arbitrary precision numbers. It takes two numbers as strings and returns an integer indicating which number is larger, smaller, or if they are equal. Syntax int bccomp(string $left_operand, string $right_operand, int $scale = 0) Parameters The bccomp() function accepts three parameters − $left_operand − The left operand as a string representing the first number to compare. $right_operand − The right operand as a string representing the second number to compare. $scale − Optional. The number of decimal places to use in the ...
Read MoreDifference between getc(), getchar(), getch() and getche()
All these functions read characters from input and return an integer. They differ in their source, buffering behavior, and echo characteristics. Syntax int getc(FILE *stream); int getchar(void); int getch(void); /* Non-standard */ int getche(void); /* Non-standard */ getc() The getc() function reads a single character from a specified file stream and returns it as an integer. It waits for the Enter key and uses buffered input. Example #include int main() { char val; printf("Enter the character: ...
Read MorePHP – How to divide two arbitrary precision numbers using bcdiv() function?
In PHP, bcdiv() math function is used to divide one arbitrary precision number from another number. The bcdiv() function takes two arbitrary precision numbers as strings and returns the result as a division of two numbers after scaling the result to a specified precision. Syntax string bcdiv($num_string1, $num_string2, $scaleVal) Parameters The bcdiv() function accepts three parameters: $num_string1 − The dividend (string type parameter) $num_string2 − The divisor (string type parameter) $scaleVal − Optional integer parameter that sets the number of digits after the decimal point in the result. Default is 0 ...
Read MorePHP – How to get the modulus of an arbitrary precision number using bcmod() function?
In PHP, bcmod() math function is used to calculate the modulus of an arbitrary precision number. The bcmod() function takes arbitrary precision numbers as strings and returns the remainder after dividing the dividend by the divisor. Unless the divisor is 0, the result has the same sign as the dividend. Syntax bcmod(string $dividend, string $divisor[, int $scale = 0]) Note − The scale parameter was added from PHP 7.2.0 version. Parameters The bcmod() function accepts the following parameters ? $dividend − The dividend that is divided by ...
Read MoreHow to print % using printf()?
In C, the printf() function uses the percent symbol (%) as a format specifier. To print the actual % character as text, you need to use a double percent (%%) because a single % has special meaning in printf() and will not display anything. Syntax printf("%%"); // Prints a single % character Example 1: Basic % Printing Here's how to print the % symbol using printf() − #include int main() { printf("Single percent: %%"); printf("Percentage: 85%%"); printf("Multiple: ...
Read MorePHP – How to multiply two arbitrary precision numbers using bcmul() function?
In PHP, bcmul() function is used to multiply two arbitrary precision numbers. This function is particularly useful when dealing with very large numbers or when you need precise decimal calculations that exceed PHP's floating-point precision limits. Syntax string bcmul(string $num1, string $num2, ?int $scale = null) Parameters The bcmul() function accepts three parameters − $num1 − The left operand as a string representing an arbitrary precision number. $num2 − The right operand as a string representing an arbitrary precision number. $scale − Optional integer parameter that sets the number of decimal places ...
Read More"register" keyword in C
In C programming, the register keyword is a storage class specifier that suggests to the compiler to store a variable in CPU registers instead of main memory. Register variables provide faster access since CPU registers are much faster than memory. However, taking the address of a register variable is not allowed. Syntax register data_type variable_name; Properties of Register Variables Scope: Local to the function in which they are declared Default value: Garbage value (uninitialized) Lifetime: Until the end of the block execution Storage: CPU registers (compiler's choice) Address: Cannot use address-of operator (&) ...
Read More