TDDE18 & 726G77 Programming in C++ Administration Examiner - - PowerPoint PPT Presentation

tdde18 726g77
SMART_READER_LITE
LIVE PREVIEW

TDDE18 & 726G77 Programming in C++ Administration Examiner - - PowerPoint PPT Presentation

TDDE18 & 726G77 Programming in C++ Administration Examiner Eric Elfving Course leader Sam Le Assistant 1 Eric Petersson Assistant 2 Alexander Johansson Assistant 3 Mathias Berggren Assistant 4


slide-1
SLIDE 1

TDDE18 & 726G77

Programming in C++

slide-2
SLIDE 2

Administration

  • Examiner – Eric Elfving
  • Course leader – Sam Le
  • Assistant 1 – Eric Petersson
  • Assistant 2 – Alexander Johansson
  • Assistant 3 – Mathias Berggren
  • Assistant 4 – Kerstin Söderqvist
slide-3
SLIDE 3

Course layout

  • Lectures
  • Lessons
  • Labs
  • 7 labs + introductory lab 0
  • Steep increase in difficulty from lab 2
  • Exam
slide-4
SLIDE 4
slide-5
SLIDE 5

Course website

All information you need to complete the course exists

  • n the course website
slide-6
SLIDE 6

Visual Studio Code

  • IntelliSense
  • Debugging
  • Built-in Git
  • Extensions

https://code.visualstudio.com/

slide-7
SLIDE 7
slide-8
SLIDE 8

Git

  • Used for lab submission and lab collaboration between you and your

lab partner

  • Try git
slide-9
SLIDE 9

Lab submissions with command line

slide-10
SLIDE 10

Lab submission with Visual Studio Code

slide-11
SLIDE 11

Sendlab

  • ~TDDE18/sendlab registration – registrating for lab work
  • ~TDDE18/sendlab start – starting a lab
slide-12
SLIDE 12

Course goal

  • Explain and compare C++ language features and be able to apply

them to relevant problems.

  • Use the programming environment and tools provided by a standard

Linux/UNIX system.

  • Explain the function of existing C++ implementations and examples.
  • Write readable, well structured solutions to small programming

problems.

slide-13
SLIDE 13

main is the start button

int main() { }

slide-14
SLIDE 14

Input and output

Program

slide-15
SLIDE 15

Output buffer

Program

slide-16
SLIDE 16

Cout

int main() { std::cout << “Hello world”; …

slide-17
SLIDE 17

Output buffer

Program Hello world

std::cout << “Hello world”; …

slide-18
SLIDE 18

Flush buffer

  • When the program exits
  • Use something to flush
  • endl
  • flush
slide-19
SLIDE 19

Flush buffer

Program Hello world

std::cout << “Hello world” << std::endl; …

slide-20
SLIDE 20

Flush buffer

Program

std::cout << “Hello world”; std::cout << “!!!” << std::endl;

? ?

slide-21
SLIDE 21

Variables

Value Type Example:

  • int x{3}
  • double y{3.14}
  • char z{‘s’}
slide-22
SLIDE 22

Input buffer

Program 3

slide-23
SLIDE 23

Cin

int main() { int x{}; cin >> x; …

slide-24
SLIDE 24

Input buffer

Program int x{0}; std::cin >> x; … 3

slide-25
SLIDE 25

Input buffer

Program int x{0}; std::cin >> x; std::cin >> x; 34 99

slide-26
SLIDE 26

String

Value Type string s{“hello”} s.size() s.front()

slide-27
SLIDE 27

Input buffer

std::string s{“temp”}; std::cin >> s; … Hello World Program

slide-28
SLIDE 28

Program

Getline

std::string s{“temp”}; std::getline(std::cin, s); … Hello World

slide-29
SLIDE 29

Includes

  • iostream
  • cin
  • cout
  • iomanip
  • setw
  • setfill

#include <iostream> int main() { std::cout >> “Hello world” >> std::endl; }

slide-30
SLIDE 30

Namespace

#include <iostream> using namespace std; int main() { cout >> “Hello world” >> endl; }

slide-31
SLIDE 31

example

int main() { int x{}; int y{}; int z{}; cout << z; }

slide-32
SLIDE 32

example

int main() { string s{}; cout << s; }

slide-33
SLIDE 33

example

int main() { int x{}; cout << setw(5) << setfill(‘0’) << x << endl; }

slide-34
SLIDE 34

example

int main() { string s{}; getline(cin, s); cout << s.front() << “ “ << s.back() << endl; } Hello World!!?

slide-35
SLIDE 35

Compile

g++ file1 [file2…] [flags]

g++ file1 g++ file1 file2 g++ file1 –Wall g++ file1 –Wextra –Wall –Wpedantic

slide-36
SLIDE 36

Lab 0

  • Wednesday at 8.15
  • All groups
  • Help will be available to setup sendlab