===================================================== SCANF ===================================================== CODE: int a,b; printf("Two Numbers A-B: "); scanf("%d-%d",&a,&b); printf("a = [%d], b = [%d]", a,b); IN: 2-3 OUT.IN: Two Numbers A-B: a = [2], b = [3] IN2: 2--3 OUT.IN2: Two Numbers A-B: a = [2], b = [-3] IN3: 2 3 OUT.IN3: Two Numbers A-B: a = [2], b = [4206072] IN4: 2- 3 OUT.IN4: Two Numbers A-B: a = [2], b = [3] IN5: 2 - -3 OUT.IN5: Two Numbers A-B: a = [2], b = [4206072] ===================================================== MORE SCANF ===================================================== CODE: int a,b; printf("Two Numbers A and B: "); scanf("%d%d",&a,&b); printf("a = [%d], b = [%d]", a,b); IN: 2 3 (single space) OUT: Two Numbers A and B: a = [2], b = [3] IN2: 2 3 (return) OUT2: Two Numbers A and B: a = [2], b = [3] IN3: 2 3 (lots of leading spaces) OUT3: Two Numbers A and B: a = [2], b = [3] IN4: 2 3 (tab) OUT4: Two Numbers A and B: a = [2], b = [3] IN5: 2--3 OUT5: Two Numbers A and B: a = [2], b = [4206072] IN6: 2-3 OUT6: Two Numbers A and B: a = [2], b = [-3] IN7: 2+3 OUT7: Two Numbers A and B: a = [2], b = [3] ===================================================== FLOATS AND INTS ===================================================== CODE: int c; int d = 8; float a,b; printf("Two Floats A B: "); scanf("%f %f",&a,&b); c = d + a; printf("c = d + a\n"); printf("a = [%10.3f], b = [%10.3f]\n", a,b); printf("c = [%10d], d = [%10d]\n", c,d); printf("d+a float = [%10.3]\n", (d+a) ); /* THIS LINE GIVES AN ERROR REMOVED FOR TESTING. SEE BELOW. printf("d+a int = [%10d], " (d+a) ); */ c = d * a; printf("c = d * a\n"); printf("a = [%10.3f], b = [%10.3f]\n", a,b); printf("c = [%10d], d = [%10d]\n", c,d); printf("d*a float = [%10.3]\n", (d*a) ); /* THIS LINE GIVES THE SAME ERROR REMOVED FOR TESTING. SEE BELOW. printf("d*a int = [%10d], " (d*a) ); */ +++++++++++++++++ DURING COMPILATION: I GET TWO WARNINGS: Compiling... main.c E:\dev\cs\testing\main.c(31) : warning C4244: '=' : conversion from 'float ' to 'int ', possible loss of data E:\dev\cs\testing\main.c(38) : warning C4244: '=' : conversion from 'float ' to 'int ', possible loss of data Linking... testing.exe - 0 error(s), 2 warning(s) +++++++++++++++++ THE ERROR I GET LEAVING IN THAT LINE UP THERE: E:\dev\cs\testing\main.c(42) : error C2064: term does not evaluate to a function E:\dev\cs\testing\main.c(42) : error C2115: 'function' : incompatible types E:\dev\cs\testing\main.c(42) : warning C4024: 'printf' : different types for formal and actual parameter 1 +++++++++++++++++ IN: 2.5 61.983 OUT: Two Floats A B: c = d + a a = [ 2.500], b = [ 61.983] c = [ 10], d = [ 8] d+a float = [] c = d * a a = [ 2.500], b = [ 61.983] c = [ 20], d = [ 8] d*a float = [] +++++++++ C is an INT +++++++++ A,B are FLOATS +++++++++ D is an INT +++++++++ All Formatting is for 10 spaces. +++++++++ Brackets are used to indicate start and end of the format specifier: [%10d] The integer replacement will appear in the 10 "spaces" between the two brackets.