Search
 
SCRIPT & CODE EXAMPLE
 

C

printf format specifiers

#include <stdio.h>

int main(){
   printf ("Characters: %c %c 
", 'a', 65);
   printf ("Decimals: %d %ld
", 1977, 650000L);
   printf ("Preceding with blanks: %10d 
", 1977);
   printf ("Preceding with zeros: %010d 
", 1977);
   printf ("Some different radices: %d %x %o %#x %#o 
", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E 
", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d 
", 5, 10);
   printf ("%s 
", "A string");
   return 0;
}

output: 
  Characters: a A
  Decimals: 1977 650000
  Preceding with blanks:       1977
  Preceding with zeros: 0000001977
  Some different radices: 100 64 144 0x64 0144
  floats: 3.14 +3e+000 3.141600E+000
  Width trick:    10
  A string
Comment

printf type format

%d--> for int

%u--> for unsigned int

%ld--> for long int or long

%lu--> for unsigned long int or long unsigned int or unsigned long

%lld--> for long long int or long long

%llu--> for unsigned long long int or unsigned long long
Comment

printf format specifiers

d decimal
c character
s string
f float
e scientific notation
x hexadecimal


 new line
	 horizontal tab
 backslash
 backspace
' single quote
" double quote
Comment

PREVIOUS NEXT
Code Example
C :: c colour 
C :: Sorting number excluding elements in highest to lowest 
C :: ruby absolute value 
C :: c get time 
C :: transpose of matrix using c program 
C :: imprimir valor no octave 
C :: get window width height glfw 
C :: c code to python code converter online 
C :: octave sum all elements in matrix 
C :: type change in c 
C :: size of an array c 
C :: how to remove from a string c 
C :: execute maven project in cmd 
C :: strcasecmp in c 
C :: c programming itoa() example 
C :: bootstrap 5 image responsive 
C :: c check if character is a digit 
C :: fractional knapsack problem in c 
C :: c print sizeof char 
C :: Counting Sort C 
C :: c check if array is empty 
C :: putchar in c 
C :: prime factorization of factorials using c 
C :: how to convert int in to const char in c 
C :: malloc basics 
C :: second largest element in an array 
C :: malloc c 
C :: signed and unsigned in c 
C :: definir função em c 
C :: Relational Operator in C language 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =