Tuesday, 15 November 2016

PRINTF and SCANF function

PRINTF function:
Printf function is defined in the header #include<stdio.h> . Printf is used for output in the C/C++ program.
Syntax:
printf("String");
Example:
#include<stdio.h>
int main()
{
       printf("Hello!");
}
output will be Hello!



SCANF function:
same like printf function scanf function also defined in header file #include<stdio.h> . Scanf function is used for taking input from user.
Syntax:
scanf("format specifiers",&variable name);
Here format specifiers are used for representing datatypes
& is used for address of variable where we want to store value from the user.
Example:
#include<stdio.h>
int main()
{
    int num;
    scanf("%d",&num);
    printf("This is value you entered=%d",num);
}
Suppose we enter 9 then output This is value you entered=9


3 comments: