Format specifier & Token in C

Ratings:
(4)
Views:0
Banner-Img
  • Share this blog:

 Format specifier & Token in C Language

Format specifier:

Format specifier will indicates that what type of data we requires to print on console   Int - %d Float-%f               Format specifiers Char-%c  

Token:

Smallest unit in programming or an individual unit in programming are called “Token” A C program is a collection of tokens Tokens can be keyword, operator, and separator, constant and any other identifier. When we’re working with the token, we can’t break the token or we can’t split the token but s/w the tokens. We can give ‘n’ no of spaces, tabs and new lines

Eg: void main(){Pri ntf(“welcome”); } o/p: error Void main{Printf(“welcome”); } o/p:welcome

  Printf-> to print anything on to the console Printf(“Hello”); Hello Printf(“****hello”); ***hello; Print(“%dwelcome%d”__ 10,20); error Function call mission(,) Printf(“%d welcome %d”,10,20); error Function call missing Printf(“%dwelcome %d”,10,20)  error Statement mission(;) Printf(“@@@welcome###”); @@@welcome### Printf(“%d welcome %d”,10,20); 10 welcome20 Printf(“%d%d%d,10,20,30”); 102030 Printf(“%d %d %d”, 10,20,30); 10 20 30 Printf(“%d %d %d”,100,200,300); 100,200,300 Printf(“2+3=%d”,2+3); 2+3=5   Within the double quotes except format specifiers and special characters rest of all content will consider as characters only. Printf(“%d*%d=%d”,2,5); 2*5=10 Printf(“%d%d  %d”,100,200); 100,200 gr/junk    gr=garbage  

  • In printf() statement, when we are passing an additional format specifier which doesn’t contains correspondent value, then it prints some unknown or undefined value called garbage / junk
  • Printf(“%d %d”,100,200,300); 100,200

  In printf() statement, when we are passing an additional value which doesn’t contains correspondent format specifiers, then that value will be ignored

  • Printf(“Total salary=%d”, 25,000);

Total salary=25

  • Printf(“total salary=%d”, 25000);

Total salary=25000

  • Printf(“%d%d”,2<5,!5!=5); 1 1

Void main() { a=25 Printf(“a=%d”,a); } o/p= Error undefined symbol ‘a’   void  main() { Int a;     // declaration a=35; // Assigning Printf(“a=%d”,a); } o/p:  a=35     Printf():- It is a pre-defined f’n, by using this f’n we can print the data on console.

  • The scientific name of the monitor is called “console”
  • When we are working with the printf, it can take any no.of arguments but 1st argument must be within the double codes and every argument should be separated with ‘,’
  • Within the double codes whatever we pass it pins assist i.e. if any format specifiers are there then copy that type of values.

 

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox