Subscribe

Header Ads

How to take input from the user using c program.

 In c program for taking input we use scanf() which is predefined in the header file stdio.h.

If we have a variable 'a' is defined as an integer then we use it by using %d in double quotes (" ")outside the double quotes we use comma mark (,) and then we write '&' before the name of variable.

 scanf("%d",&a);

for integer we use %d

for char we use %c

for float we use %f

Here is a program to make it more clear


#include<stdio.h>

int main()

{

        int a;

        printf("Enter a number = ");

        scanf("%d".&a);

        return 0;

}




Post a Comment

0 Comments