Wednesday, 15 September 2010

06. How to use scanf

Many new C programmer having problem to use scanf. Today i want to write something about use of scanf. Scanf is a function We use it for input. If i need to input something to a user then i simply use scanf.  Look at this cord.

Cord:

/* Use of scanf */

#include<stdio.h>
main()
{
int a;
printf("Enter a number: ");
scanf("%d",&a);
printf("%d",a);
getch();
}


In this cord I use printf and scanf. In printf function there is no( & ), but in scanf there mast be a (&) remember it. See when we use scanf  we first declared what the variables type was
"%d" for int ,"%f" for float ,%e for double ,"%c" for char , "%s" for strings.

  Hear i use scanf for input something. Then i use printf to print that thing which i get input.

Writern by arnob

No comments:

Post a Comment