Introduction To Computer Science PDF Fall 2024

Document Details

FervidDune

Uploaded by FervidDune

ETH Zurich

2024

ETH Zurich

Manuela Fischer and Felix Friedrich

Tags

computer science programming integers expressions

Summary

These lecture notes are from a Computer Science course at ETH Zurich, Fall 2024. They cover arithmetic expressions and rules of precedence and associativity in programming.

Full Transcript

INTRODUCTION TO COMPUTER SCIENCE 252-0032, 252-0047, 252-0058 Document authors: Manuela Fischer and Felix Friedrich Department of Computer Science, ETH Zurich Fall 2024 1 Integers and Expressions...

INTRODUCTION TO COMPUTER SCIENCE 252-0032, 252-0047, 252-0058 Document authors: Manuela Fischer and Felix Friedrich Department of Computer Science, ETH Zurich Fall 2024 1 Integers and Expressions 30 Section 3 Integers and Expressions In the previous introductory chapter you have learned that a computer program contains statements that can contain expressions. In this section we will have a closer look at the semantics of expressions. As it will turn out, rules of precedence and associativity are unsurprisingly close to what we would expect from a mathematical point of view. Subsection 3.1 Arithmetic Expressions In order to understand the rules for evaluating of mathematical expressions, let us have a look at another example. Code 3.1 comprises a program to convert a number from degrees Celsius to degrees Fahrenheit. 1 // Program: fahrenheit.cpp 2 // Convert temperatures from Celsius to Fahrenheit. 3 #include 4 5 int main() { 6 // Input 7 std::cout > celsius; 10 11 // Computation and output 12 std::cout

Use Quizgecko on...
Browser
Browser