List 12 format specifiers in C each with its usage and example


List 12 format specifiers in C each with its usage and example

List 12 format specifiers in C each with its usage and example:


Format Specifier in C
 Used With scanf() Statement
  1.  %c  - Read a character
  2.  %d  - Read a decimal integer
  3.  %e  - Read a float
  4.  %f  - Read a float
  5.  %g  - Read a float 
  6.  %h  - Read a short integer
  7.  %i  - Read a decimal / Hexadecimal / octal integer
  8.  %o  - Read an octal integer
  9.  %s  - Read a string of Characters
  10.  %u - Read an unsigned integer
  11.  %x - Read a hexadecimal integer
  12.  %[...] - Read a string of words

%c : It is used for reading a character. A character can be anything between 'a' - 'z' and a character is always represented in single quotes. or it can 'A' - 'Z' , or any characters.

%d : It is used to read a decimal integer. Any digit that builds up using 0-9 is a decimal integer. example - 19 where 1 lies between 0-9, 9 also lies between 0-9. 

%e / %f / %g : A float value means a Real Number such as 31.43,31.47,4.4347 . 

%h : It is used to read an short integer. Short integer are in the range -128 to 127(Signed Short integer) . in Unsigned short integer the Range is 0-255.

%i : It is used to Read a Decimal / hexadecimal / octal decimal  values. 

hexadecimal is a number that can be build using '0-9', 10 is represented as A , 11 is represented as B , 12 can be represented as C , 13 can be represented  as D , 14 can be represented as E, 15 can be represented as F. Example 4A3 is a hexadecimal integer.

Octal integer is a integer or a number that is build using 0-7.

%S : It is used to read the string of characters. example "Piyush" there are 6 character

%U : It is used to Read Unsigned Integer.the integer can be read by using %u onlu unsigned

%[...] : This Format specifier is used to read a string a words . Such as "Coding Gyaan" is a string of words.

Searching For Gov Jobs https://govtjobssnow.in

0 Comments