Ad Code

Responsive Advertisement

C-input&output-command: printf() & scanf()

 


                    Printf() and Scanf() [Input&output commands]


     Printf() and Scanf() are other facilities of c-language from which first is for output and other for input.

Scanf is used with printf while printf can be used separately.

Printf syntax:

see the post: https://c-codingworld.blogspot.com/2021/02/coutput-commandprintf.html

Scanf SyntaX

1_

        scanf("data specifiers",&argument_List);

Data-specifiers: %d, %f, %c etc...

Argument_list: Variables assigned before.


EXAMPLE#1:

    #include<stdio.h>

   main()

   {

     int a;

     float b;

     printf("Enter  numbers:");

     scanf("%d %f",&a,&b);

    printf("values of a is %d And value of b is %f",a,b);

  }

EXAMPLE#2:

#include<stdio.h>

main()

{

   int a,b,c;

   printf("Enter a number:");

   scanf("%d",&a);

   printf("Enter second number:");

   scanf("%d",&b);

   c=a+b;

   printf("Value of c =%d",c);

}

NOTE:  This program gives values of two variables a and b and returns the value of c which will be the sum of variables a and b. 
This program can be used as an addition, subtraction, multiplication, division, and modulus. 

        


------------------------------*****************---------------------------------

Reactions

Post a Comment

0 Comments