C By Discovery (4th Edition)

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

View Full Document Right Arrow Icon
Intermediate Programming CSE 1320 Lecture 04 Chapter 2: 2.5-2.8 while Loop • Iterative construct while (expression) statement while (correct == 0) correct = process(); getchar() and putchar() • getchar: reads a character from the keyboard and returns the corresponding integer value as type int • putchar: takes an argument of type int and outputs the corresponding ASCII character on the terminal screen #include <stdio.h> int main(void) { int iochar; while ((iochar = getchar()) != EOF) putchar(iochar); return 0; } Logical Operators and Expressions combine control expressions ! logical-not exp1 !exp1 true false false true exp1 exp2 true true true true false false false - false || logical-or exp1 exp2 exp1 || exp2 true - true false true true false false false Logical Operators and Expressions i = 3; j = 0; printf(“%d\n”, i || ++j); printf(“%d\n”, j); printf(“%d\n”, j & i++); printf(“%d\n”, i); Precedence of Logical Operators logical-not
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/06/2011 for the course CSE 1320 taught by Professor Sprintston during the Spring '08 term at UT Arlington.

Page1 / 2

Lecture04 - while Loop Intermediate Programming CSE 1320...

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

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