Wednesday 18 May 2011

How to take an input from user? scanf() function

scanf() is used to take input from user. It is very useful and easy function to use.


Syntax:


scanf("format specifier",&variable);


Lets have a look to following example:


{
int num;
printf("Enter a number:");
scanf("%d",&num);
}


Now, in the above example, the value given by the user will store in the variable 'num'.


If you have any question, please ask me freely...

0 comments:

Post a Comment