/* File: scanf3a.c Test use of the scanf() function to read in user input What happens if you use %f instead of %lf? If you compile this with -Wall, gcc will catch this error for you!!!! */ #include // Let's make main() return an int. int main() { int n ; double x ; char name[101] ; // this is a string or char array printf ("Enter an integer value for n: ") ; scanf("%d", &n) ; // don't forget the ampersand printf ("Enter a floating point value for x: ") ; scanf("%f", &x) ; // double requires %lf, not %f printf ("Enter your first name (no spaces): ") ; scanf("%100s", name) ; printf ("Hello %s, you typed in %d for n and %f for x.\n", name, n, x) ; return 0 ; // 0 means no error to report }