what is the difference between printf and scanf?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bilal ahmad
    New Member
    • Feb 2013
    • 1

    what is the difference between printf and scanf?

    what is the difference between printf and scanf?
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    printf is a means to send information out of your program to a user (output).

    scanf is a means to pull information from a user into your program (input).

    Comment

    • VanessaMeacham
      New Member
      • Sep 2012
      • 31

      #3
      HI ! printf will print the data you ask from the program to print, like for example if you have an int a, and you have put the value 1 to it, you can write in the program printf("The value of a is: %d\n",a); %d will print the integer after the comma, and the \n will move the cursor a line down after the printing, so you'll have printed:
      The value of a is: 1

      scanf reads data. For example you can have scanf(“%d”,&k); if you have an int k, before that, and it will read the value of k that the user will give and put it in k.

      Comment

      • suvarna271
        New Member
        • Feb 2013
        • 19

        #4
        scanf is for taking input from the user. the user input is interpreted as per the format specifier(%c, %d, %u etc) specified. It requires the address of the variable in which the value is to be stored. This is given by &(variable name)

        printf is used for displaying data to the user. The output is formatted as per the format specifier used (%c, %d, %u etc).

        Comment

        Working...