Introduction To Computer Science PDF Fall 2024

Summary

This document is an introduction to computer science, focusing on integers and expressions. The document was published in Fall 2024 by ETH Zurich. It is written by Manuela Fischer and Felix Friedrich.

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