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 ecture 2 1 CMSC 212 Lecture 2 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 DocumentRight 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.: rints a newline 5 CMSC 212 \n prints a newline \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 atches a decimal integer 6 CMSC 212
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.

This note was uploaded on 11/23/2009 for the course CMSC 212 taught by Professor Staff during the Spring '08 term at Maryland.

Page1 / 5

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online