1 Introduction & Syllabus Computer Hardware/Software Hierarchy C / C++ Problem Solving / OOAD Development Environment / Tools Simple C++ program structure Linux, g++ & dropboxes CSE 20232 CSE 20232 Lecture 1 - Preliminaries Lecture 1 - Preliminaries
22
Embed
1 Introduction & Syllabus Computer Hardware/Software Hierarchy C / C++ Problem Solving / OOAD Development Environment / Tools Simple C++ program structure.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Introduction & Syllabus Computer Hardware/Software Hierarchy C / C++ Problem Solving / OOAD Development Environment / Tools Simple C++ program structure Linux, g++ & dropboxes
Control unit -- fetch-execute cycle ALU (arithmetic logic unit)
Software Operating System (Linux, Windows, UNIX, …)
Interpret commands and manage access to resources Application (Word, FreeCell, Doom, …)
Provide productivity tools, entertainment Create a “virtual” machine
5
Programming Language Preliminaries
Language hierarchy Machine language
numeric codes for basic hardware operations Assembly language
mnemonic codes for basic hardware operations load, add, store, …
High-level language (Pascal, C/C++, Java, Ada …) English-like instructions and constructs for combinations of
basic hardware operations x = 3; if (x < y) x = y;
6
Programming Language Preliminaries
Interpreter Reads, translates and executes program
instructions on the fly Compiler
Translates high-level source code into relocatable object code (assembly or machine)
7
C / C++ History
BCPL (Martin Richards 1967) For writing compilers and operating systems
B (Ken Thompson 1970) Based on BCPL & used to create early version of UNIX at
Bell Labs
C (Dennis Ritchie) Evolved from B & BCPL Became the development language for UNIX C programs can be portable (platform independent) Standard is ANSI/ISO 9899; 1990
8
C / C++ History
C++ (Bjarne Stroustrup – early 1980’s) Extension of C Supports Object-oriented programming User definable object classes Facilitates development of reusable software components
C++ Standard Library LARGE Collection of existing classes & algorithms
C++ Basics Comments are for humans and are ignored by the compiler
// rest of line after double slash is ignored /* everything between markers is ignored */
Include directives load predefined code interfaces so compiler “knows” about functions, classes, and other predefined entities #include <iostream>
loads C++ header from “normal” location Headers define entities within namespaces
#include <stdlib.h> loads C-style header from “normal” location No namespaces
#include “myStuff.h” Loads user-defined header from current directory May or may not contain namespaces
14
Simple C++ Program (helloWorld.cpp)
// file: helloWorld.cpp// author: J H Stewman// date: 8/22/2006// purpose: CSE 20232 – Notre Dame – demo// description:// this shows the world we care#include <iostream>using namespace std;int main( ){ cout << “Hello World!” << endl; return 0;}
15
Simple C++ Program (helloWorld2.cpp)// file: helloWorld2.cpp// author: J H Stewman// date: 8/22/2006// purpose: CSE 20232 – Notre Dame – demo// description:// shows the world we care // (with scope resolution operator ::)#include <iostream>
Simple C++ Program (addTwo.cpp)// file: addTwo.cpp// author: J H Stewman// date: 8/22/2006// purpose: CSE 20232 – Notre Dame – demo// description: ages you by two years#include <iostream>using namespace std;int main( ){ int age; cout << “Hello, what is your age? ”; cin >> age; cout << “In two years you will be ” << age + 2 << endl; return 0;}
17
UNIX/Linux Basics Basic commands
ls list current director contents cd change to another directory mkdir, rmdir make or remove a directory (folder) pwd displays current path rm remove a file mv move or rename a file cp copy a file less page through a text file man display manual page on command
18
UNIX/Linux Basics
Basic commands !! “bang bang” execute last command !x execute last command x* | pipe output of one command into another history show list of previous commands ln - s create symbolic link < take input from file > send output to file >> append output to file