INPUT NUMBER FROM THE KEYBOARD
Although there are actually several ways to input numeric values from the keyboard, one pf the easiest is to use another of C's standard library functions called scanf() .
To use scanf() to read an integer value from the keyboard,call it using
the general from......
scanf("%d", & int-var-name);
[where int-var-name is the name of the integer variable you wish to receive the value.]
Example:
int main(void)
{
int A; float B;
printf("\n Enter an integer: ");
scanf("%d", &A);
printf("\n Enter a floating point number: ");
scanf("%f", &B);
return 0;
}
Output |
No comments:
Post a Comment