{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture02 - Last time Introduction to Low-Level Programming...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Low-Level Programming Concepts CMSC 212 Lecture 2 1 CMSC 212 September 3, 2009 Last time Introduction and motivation Low-level programming Stored program computer concepts assembly language fetch/decode/execute cycle the UNIX and C memory model 2 CMSC 212 Chapter 1, A quick start with C – formatting – declarations the C preprocessor ( #include ) Chapter 2, Basic concepts the compilation process and stages of compilation Reading Read Chapter 4 in Reek (Pointers on C) Reminder: read the UNIX tutorial on the class webpage 3 CMSC 212 Chapter 2, Basic Concepts, con't. 4 CMSC 212
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Output- the printf() function Its declaration is included with #include <stdio.h> Syntax: printf(" formatstring ", expr 1 , expr 2 , expr 3 , ); it's a function with a variable number of arguments In the formatstring : escape sequences (similar to Java) have special effects, e.g.: \n prints a newline 5 CMSC 212 \t prints a tab character – a format specifier prints the value of the corresponding expression: %d prints an integer in decimal %f prints a floating-point value %c prints a character %s prints a character string all other characters print as themselves Example, assuming int a= 212; printf("%d is smaller than %d\n", a, a + 38); Input- the scanf() function Its declaration is also included with #include <stdio.h> Syntax: scanf(" formatstring ", & variable 1 , & variable 2 , & variable 3 , ... ); the variable names must all be preceded by & In the formatstring : the same kinds of format specifiers as in printf() are used to match data entered in the input: %d matches a decimal integer 6 CMSC 212 %f matches a floating point value %c matches a character
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}