Class Notes (835,539)
Canada (509,225)
CSC209H1 (41)
Karen Reid (20)
Lecture

jan25c.docx

1 Page
44 Views
Unlock Document

Department
Computer Science
Course
CSC209H1
Professor
Karen Reid
Semester
Winter

Description
 C Data Types o Output: o Basic types and literals (see King CH7) $ gcc -Wall -o dataType dataType.c  Integer numbers dataType.c: In function ‘main’: dataType.c:32: warning: format ‘%d’ expects type  can be long/short & signed/unsigned ‘int’, but argument 2 has type ‘long unsigned  oct & hex different ways of writing numbers int’  long has suffix L, oct has prefix 0, hex has prefix 0x  string formatting %d converts to integer number dataType.c:32: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int i = 38; int’ long el = 38L; dataType.c:33: warning: format ‘%d’ expects type int hex = 0x2a; ‘int’, but argument 2 has type ‘long unsigned int oct = 033; int’ printf("i = %d, el = %ld, hex = %d, dataType.c:33: warning: format ‘%d’ expects type oct = %d\n", i, el, hex, oct); ‘int’, but argument 2 has type ‘long unsigned  Output: int’ i = 38, el = 38, hex = 42, oct = 27 dataType.c:34: warning: format ‘%d’ expects type  Float numbers ‘int’, but argument 2 has type ‘long unsigned  Can be float/double/long double int’  Optional exponents preceeded by E (or e), optional +/-ataType.c:34: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned  String formatting %.pf converts to floating point numint’ with p indicating how many demical places double d1 = 0.3; $ ./dataType double d2 = 3.0; c is A and i is 65 \\ line 6 double d3 = 6.02e23; and c as int is 65 \\ line 7 and d is 65.000000 \\ line 8 printf("d1 = %.1f, d2 = %.2f, d3 = %e\n", d1, d2, d3) c is ? and i is 500 \\ line 11  Output: and c as int is -12 \\ line 12 d1 = 0.3, d2 = 3.00, d3 = 6.020000e+23 o C literals and types c is A and i is 500 \\ line 14  A literal is a constant expressed in code and c as int is 65 \\ line 15 Literal Value Type 38 38 Int d is 4.300000e+50 and i is -2147483648 \\ line 18 38L 38 long int 0x2a (hex) 43 int c = 127 \\ line 20 033 (octal) 27 int c = -128, d = -4.000000 \\ line 23 38.0
More Less

Related notes for CSC209H1

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit