C: printing long double using printf
If you want to use very large floating numbers in C beyond what can be stored using double, use long double.This is useful for large scale scientific computations Printing a long double is shown here #include <stdio.h> int main() { /*Floating point number – double*/ long double fvar = 25.01; /*Printing size of a double*/ [...]
C: printing double using printf
If you want to use large floating numbers in C, you can use double instead of float. Printing a double is shown here #include <stdio.h> int main() { /*Floating point number – double*/ double fvar = 25.01; /*Printing size of a double*/ printf ("Size of double %i bytes\n", sizeof(fvar)); /*Printing double*/ printf ("%lf\n", fvar); printf [...]
C: Printing float using printf
float in C is used to represent floating point numbers. It’s declaration is as simple as float varname; The following program shows how to print a float. #include <stdio.h> int main() { /*Floating point number*/ float fvar = 25.0; /*Printing floating point number*/ printf ("%f\n", fvar); return 0; } Let’s check the output 25.000000 The [...]
C: Printing unsigned/signed long long int using printf
If you want to use large integer numbers which cannot be represented using 4 bytes, you can use long long int instead of int. A long long int occupies 8 bytes. But you can make use of the sizeof operator to find the size of a long long int. Two types of integer are supported [...]
C: Printing unsigned/signed long int using printf
If you want to use integer which occupies 4 bytes, you can use long instead of int. Note that such a case is useful in cases where your compiler supports only 2 bytes int. In case of gcc compilers and a normal x86 machine, both int and long int occupy 4 bytes. Two types of [...]
C: Printing unsigned/signed short using printf
Two types of integer are supported in C: signed and unsigned integers. If you want to use integer which occupies only 2 bytes, you can use short instead of int. To declare a signed short integer signed short int varname; To declare a unsigned short integer unsigned short int varname; If you do not specify [...]
C: Printing unsigned/signed integer using printf
Two types of integer are supported in C: signed and unsigned integers. To declare a signed integer signed int varname; To declare a unsigned integer unsigned int varname; If you do not specify a specifier with int, it is taken as signed integer. To print signed integer, you can either use i or d. For [...]