Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
Format Specifier C
Question Posted on 21 Aug 2020

Home >> Tutorial >> C Language >> Format Specifier C


Format Specifier C
Format specifier is string which is used in formatted input and output functions. And we use format string determines the format of input and output. Format string always starts with a "%" character.

Below are the most commonly used format specifiers in and printf() and scanf() function are given below.


Format Specifier C

Example for Format Specifier


(1)Use of %d in C program


Format Specifier %dIn above example we use %d to print integer value of x and y

Output:-
Value of x is:2
Value of y is:4


(2)Use of %u in C program


Format Specifier %uIn above program we use %u to display value of x and y by using unsigned format specifier. Here value of x is positive and for negative value it not print value of c and will change the value of -10.

Output:-
Value of x is:10
Value of y is:4294967286


(3)Use of %o in C program


Format Specifier %oIn above program we will get value of octal and integer for a specific common value.

Output:-
Octal Value of x is:100
Integer Value of x is:64


(4)Use of %X and %x in C program


Format Specifier %xXIn above code y contains the hexadecimal value "A" and it is shown in two format one is "a" and another is "A" which is smaller and capital X. ANd when we use %d then it is shown in integer values.

Output:-
Hexadecimal Value of y is:a
Hexadecimal Value of y is:A
Integer Value of y is:10


(5)Use of %f in C program



Format Specifier %fIn above code will print value of y as floating upto 6 characters

Output:-
Floating point value of y is: 3.400000


(6)Use of %e in C program


Format Specifier %eIn above code output will be exponent part will be print

Output:-
Exponential value of y is: 3.000000e+00





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |