lec4 - CS240: Programming in C Lecture 4: Operators and...

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

View Full Document Right Arrow Icon
CS240: Programming in C Lecture 4: Operators and Expressions. Control Flow. 1 Sunday, January 23, 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
Example #include<stdio.h> int main() { int fahr, celsius; const int lower = 10, upper = 300, step = 10; fahr = lower; while (fahr <= upper) { celsius = 5* (fahr - 32) / 9; printf("%d\t%d\n", fahr, celsius); fahr = fahr + step; } return 0; } 2 Sunday, January 23, 2011
Background image of page 2
Example #include<stdio.h> int main() { int fahr, celsius; const int lower = 10, upper = 300, step = 10; fahr = lower; while (fahr <= upper) { celsius = 5* (fahr - 32) / 9; printf("%d\t%d\n", fahr, celsius); fahr = fahr + step; } return 0; } 10 -12 20 -6 30 -1 40 4 50 10 60 15 70 21 80 26 90 32 100 37 110 43 120 48 130 54 140 60 150 65 160 71 170 76 180 82 190 87 200 93 210 98 220 104 230 110 240 115 250 121 260 126 270 132 280 137 290 143 300 148 2 Sunday, January 23, 2011
Background image of page 3

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

View Full DocumentRight Arrow Icon
Operators Arithmetic: +, -, *, /, % Relational: <, >, <=, >=, !=, == Logical: Increment/decrement: ++, -- Bitwise: Assignment: =, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |= 3 Sunday, January 23, 2011
Background image of page 4
int bitcount(unsigned x) { int b; for (b=0; x != 0; x >>= 1) b++; return (b); } what does bitcount(32) return? bitcount(15)?
Background image of page 5

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

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

Page1 / 20

lec4 - CS240: Programming in C Lecture 4: Operators and...

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

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