programminghead Logo

How to Use Format Specifier in C Programming:

In Printf (For Output)

To Print any Data To Output Screen We Use printf() Function. But for Printing Variable's data we have to Use Format Specifiers inside Printf() function's String, and after the String we Write out Data Type Nane/Variable's Name and separates the String The The variable's Value We Use Comma before Variable name

int a=5;

here we first Declared The Variable (int) to store a Integer Value, Then We gave Our Variable name (a) and the value 5, After This we used Printf() function To print out values to Output Screen
Formate Specifier work like a PlaceHolder. like it Export Or print the values where the Formate Specifier is Declared.

inside the printf() function's strings we write the %d (Formate Specifier For Integers) and after the comma we write our Variable name.

Example 1:

void main()

     int a=1;
     printf("Value = %d",a);



Value = 1

Example 2

void main()

     int a=1;
     printf("%d = Value",a);



1 = value

C Format Specifier Example

void main()

     int a=1;
     char b='z';
     float c=3.5;
     char d[15]="programminghead";
     printf("a =%d",a);
     printf("\nb =%c",b);
     printf("\nc =%f",c);
     printf("\nd =%s",d);



a =1
b =z
c =3.500000
d =programminghead

Example (Explained):

#include<stdio.h> :

#include<stdio.h> is a Header file that includes Slandered (str) Input Output (IO) Library/File. Because All Of the C's In build Functions are declared in <stdio.h> File

main() :

main() (main function) is the entry point of C program. When We Run our C program the execution Control Directly to the main() (main function) and gave us result in output.

printf() :

printf() is also a Function of C. Printf() is used to print “character, string, float, integer,etc” to the output screen.
So what ever we write between printf() inverted commas (" ") that will be printed on the output Screen


minecraft for free
12:59 pm

Hey there! This is my first comment here so I just wanted to give a quick shout out and tell you I really enjoy reading your articles. Can you recommend any other blogs/websites/forums that deal with the same topics? Thanks a ton!

minecraft free
10:29 pm

Hurrah, that's what I was searching for, what a information! existing here at this blog, thanks admin of this web site.

04:51 pm

I read this paragraph fully on the topic of the difference of most up-to-date and previous technologies, it's awesome article.

03:29 pm

Hi, just wanted to say, I loved this article. It was funny. Keep on posting!

08:31 am

An outstanding share! I have just forwarded this onto a colleague who was doing a little research on this. And he actually bought me dinner because I stumbled upon it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanx for spending the time to discuss this matter here on your web page.

how to download minecraft
06:35 pm

Hello, I enjoy reading through your article. I like to write a little comment to support you.

download minecraft for free
01:15 pm

I simply couldn't leave your website before suggesting that I actually loved the standard info a person provide on your guests? Is going to be again ceaselessly to inspect new posts

minecraft download for free
10:11 pm

What's up to all, how is everything, I think every one is getting more from this web site, and your views are good in favor of new users.

minecraft free download pc
11:37 am

May I just say what a comfort to find someone who truly knows what they are talking about on the net. You certainly know how to bring a problem to light and make it important. More and more people need to read this and understand this side of the story. I can't believe you are not more popular since you definitely have the gift.

gamefly free trial
04:13 am

Great beat ! I would like to apprentice while you amend your website, how can i subscribe for a blog website? The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear concept

gamefly free trial
08:06 am

Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your website? My blog site is in the exact same niche as yours and my users would truly benefit from a lot of the information you present here. Please let me know if this okay with you. Many thanks!

08:15 am

Thanks for finally talking about >Formate Specifier in C : Introduction and Use with Example

gamefly free trial
05:21 pm

Very good article. I will be facing a few of these issues as well..

gamefly free trial
03:00 am

Oh my goodness! Awesome article dude! Thank you, However I am having issues with your RSS. I don't know the reason why I can't subscribe to it. Is there anybody else having the same RSS problems? Anyone that knows the solution can you kindly respond? Thanks!!

Write to Us