C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Output

Enter a number

4

Number=4

The scanf() function is used to take input from user. In this program, the user is asked a input and value is stored in variable c. Note the '&' sign before c. &c denotes the address of c and value is stored in that address.

I/O of floats in C

#include <stdio.h>

int main(){

float a;

printf("Enter value: ");

scanf("%f",&a);

printf("Value=%f",a); //%f is used for floats instead of %d

return 0;

}