C By Discovery (4th Edition)

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

View Full Document Right Arrow Icon
1 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 && logical-and exp1 exp2 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 logical-and (left associative) logical-or (left associative) i || j || k is (i || j) || k
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern