Printf() and scanf() function in c language

    

   The  printf()  and  scanf()  functions  are  used  for  output  and  input in  c  language. Both  functions  are  inbuilt  library  functions, defined  in  stdio.h  (header files).
  
 printf() function :-
  
 The printf()  function  is  used  for  output. It  prints the given statement  to  the  console.


   
   For  example:-
 
        #include<stdio.h>
        int main()
{
   printf("Hello  World");  // printf()  function
  return 0;
}
  out put:  Hello  World
  
     scanf(_) function :-
    

            The   scanf() function  is  used  for  input. It  reads  the input data  from  the  console.
      

for   example:
        
   #include<stdio.h>
   int main()
{
  int  a, b, sum;
   printf("Enter the value  of  a and b=  ");
   scanf("%d%d",&a,&b);  // scanf() function
   sum=a+b;
   printf("Addition is = %d",sum);
   return 0;
     
   } 

    out  put:

             Enter the value of a and b= 12  &  29

           Addtion is = 41

                       

Post a Comment

Comment from message

Previous Post Next Post