• Call Us: +91 9437911966
  • Email Us: info@studentstutorial.com
  • Home
  • C Examples
  • Server Side
    • PHP
    • Java
    • CodeIgniter
    • Laravel
    • JSP
    • JDBC
  • Frontend
    • HTML
    • CSS
    • Javascript
    • jQuery
    • AJAX
    • FPDF
    • TCPDF
  • APP & DB
    • Android
    • Cordova
    • SQL
    • Oracle
  • Project
C Tutorial C Introduction C Characteristic C Comments C Operator C Assign Operator C Arithmetic Oper.. C Logical Operator C Modulus Operator C Variable C Initialise Variable C Print F C Translators C Programming C Control Flow C If Else Statement C Nested If Else C Loops C While Loops C For Loops C Do While C Nested Loops

Print – F () in C

  • Students Tutorial
  • 08 jun 2020
   

It is predefined fn which is declared in < stdio.h >

By using predefined fn, we can print the data on console.

When we are working with printf ( ) function, it can take any no.of arguments but first asg must be starting constant & remaining arguments all separated by comma.

Within the “ “ double quotes, whatever we pass, it bring it like that only, if any format specifies are these, then copy that type of data.

Syntax: -

Format Specifiers

  1. All format specifies will decide that what type of data required to print on console
  2. Designing a prog on Linux OS

    1. Open the terminal and type following command VI file 1.c
    2. To make typing enabled just press I button & type prog.

    # include < stdio.h >

    Int main ( )
    {
       Printf (“ Students tutorials”)
          Return.o;
    }
    
    

    o/p: Students tutorials

  3. Press Esc button, then write following command Wq(writing quilt)
  4. For compiling and linking the page, we are required to use the following command.
    Gcc-o file 1 file 1.c.
  5. To load or execute d prog, we required to use following command.
    % file 1
  1. Stdio.h provides standard i/o related predefined functions prototypes → just declaration not implementation.
  2. .H file doesn’t provides any implementation past of predefined functions, it provides only prototype i.e. forward declaration of function.
  3. Void main ( ) fn doesn’t provide any exit status back to the os.
  4. Int main ( ) fn provide exit status back to the os i.e. success or failure.
  5. If we are required to provide exit status or success, then return value is o i.e. return o; or return EXIT- SUCCESS
  6. When we are required to inform exit status or failure, then return value is 1 i.e. return 1; or return EXIT-FAILURES.

Token

  1. Smallest part of programming or an individual part of programming is called
  2. A C prog is a combination of tokens.
  3. Tokens can be keyword, operator, separator, constant and any other identifiers.
  4. When we are working with tokens we can’t spilt data token or we can’t break the token but b/w the tokens, we can keep any no.of spaces, tabs and newline characters.
Void main ( ) Void
{ Main
Print (“welcome) (
} )
o/p: Error {
  1. Print F (‘ Hello”); Hello
  2. Print F ( “ @ @ welcome # # “); @ @ welcome # #
  3. Print F (“ % d welcome % d” 10,20); Error Function call missing“ “10 not separated by comma.
  4. Print F (“ % d welcome % d”, 10,20); Error Function call missing 20, separator these, compiler waits for one more argument.
  5. Print F ( “ % d welcome % d”,10,20) Error Statement missing
  6. Print F (“ % d welcome % d”, 10,20); 10 welcome 20 In print f statement when we are passing format specified then at the time of execution automatically format specified we replaced with corresponding value.
    1. Print F (“ % d % d”,10,20,30); 102030 no clarity
    2. Print F (“ % d % d”, 10,20,30); 10, 20, 30
    3. Print F (“ % d, % d, % d”, 10,20,30); 10, 20, 30

    Within the double quotes of a print F everything is treated like normal characters only except format specifiers & special characters.

  7. Print F (“2+3 = % d”, 2+3);
    2+3 = 5
  8. Print F (“% d % d % d”; 100,200);
    100 200 → Garbage / junk value
  9. Print F (“% d % d”, 100, 200, 300);
    100, 200
  10. In print F statement when we are passing an additional format specified which doesn’t have corresponding value then it brings some unknown or undefined value called garbage / junk.

    In print f when we are passing an additional value. Which doesn’t have corresponding format specifies then that value is ignored because format specifies only decided data what type of data is required to print on console.

  11. Print f (“Total salary = % d”, 25,000);
    Total salary = 25
  12. Print F (“Total salary = % d”, 25000);
    Total salary = 25000
  13. Print f (“Total salary = % d”);
    Total salary = gr/ junk
  14. Print F (“% d % d”, 2> 5, 5< 8);
    O/p 0 1

Void main ( )

{
   A = 10;
   Print f (“a = % d”, a);
}


Error: undefined symbol ‘a’

Void main ( )

{
Int a;   // variable declaration
A= 10;  // Assignment
Print f (“a= % d”. a);
}

O/p: a= 10

Student Tutorial is a online tutorial for web design and development. Here you can find easy example and explanation for each tutorial.
Copyright © 2016-2023 Student Tutorial

Server Side

  • PHP
  • Java
  • CodeIgniter
  • Laravel
  • JSP
  • JDBC

Frontend

  • HTML
  • CSS
  • Javascript
  • jQuery
  • AJAX
  • FPDF

App & Database

  • Android
  • Cordova
  • SQL
  • Oracle