The Printf () function

Printf is a function in c language. We will discuss about the functions in different in deep . Lets have a look at the printf() function. 

The printf function is used to display information required to the user and also prints the value of the variables . We also uses a semi colon at the end of the braces of printf function. 

We can use printf function in three different ways:- 
These are as follows :- 
  1. Printf("string to be printed"); 
  2. Printf("format specifier", variable list); 
  3. Printf("string with format specifier",variable list); 

Example 1: C Output

#include <stdio.h>
  
int main()
{
   // Displays the string inside quotations
  printf("Welcome to the field of programming");
    return 0;
}

Output  

"Welcome to the field of programming"  

The Scanf() Function

The scanf() is used to read Formatted data from the keyboard . The syntax of the scanf() function can be given as 

Scanf("format specifier", variable list);

The format specifier specifies the types and format of the data that has to be obtained from the keyboard and stored in the memory locations. 

scanf("%d",& variable name ); 

Example 1: Add two numbers.

#include <stdio.h>
  
int main()
Int a; Int b; Int c;
{
    // Displays the string inside quotations
  printf("enter two numbers to add");
Scanf("%d%d",a,b );
C=a+b; Printf(" sum is : %d",c);
    return 0;
}

Output  

enter two numbers to add 10,5

=15