160 likes | 300 Views
Computer Science 117. Intro to C++ 08/26/13. Today. Discuss Syllabus Brief History of C++ How to Execute a C++ program. Reading assignment. Computer Science 117. Beginning Level Course No Previous Programming Assumed Quite a Bit of Time Spent on Programs and Reading. Syllabus.
E N D
Computer Science 117 Intro to C++ 08/26/13
Today • Discuss Syllabus • Brief History of C++ • How to Execute a C++ program. • Reading assignment
Computer Science 117 • Beginning Level Course • No Previous Programming Assumed • Quite a Bit of Time Spent on Programs and Reading
Syllabus • You should have a copy
Programming • What is a Program? • What is a Programming Language?
C/C++ and linux • UNIX written 1969 by Thomas & Ritchie • Bell Labs, PDP-7 • C written in early 1970’s by Dennis Ritchie • UNIX rewritten in C by Thomas in 1973. • C++ written in early 1980’s by Bjarne Stroustrup http://www2.research.att.com/~bs/ • Object Oriented Programming (OOP) • Linux written in 1991 by Linus Torvalds
Where is C++ Used? • Just about everywhere • Mars rovers, animations, graphics, industrial controllers, compilers, chip manufacturing, etc.
#include <iostream> using namespace std; // Program to figure gravitational force on Mars int main() { double mass, g; double force; cout << "Mass (kg)>"; cin >> mass; g = 3.7; force = mass * g; cout << force << " newtons\n"; return 0; }
Classes and Objects • To create two objects of type Planet: class Planet { // class definition }; Planet earth, mars;
Executing a C++ Program • Login to onyx. • Edit the program -- using vi or vim or gvim • Compile the program • Execute the program • How to do this.
Login and Password • I will hand it out. • Don’t lose it. • Keep the password a secret.
mobaxterm • Start it from the start up menu • Then: ssh -Y login@onyx
Logout • exit • Important
vi • Type "vi" at the prompt • Two modes • Command • Insert
vi Commands • a, i – get into insert mode • <esc> – back to command mode • x– delete a character • dd, 10dd– delete a line, delete 10 lines. • dw – delete a word • u– undo • :n – Get to line n • :wq– save and quit • :q!– quit w.o. saving • arrow keys– move around
Assignments • Read in Linux Guide through “Printing Files” • Link off my 117 web page. • Read the Quick Reference to the vi Editor. • Link off my 117 web page • Read the vi reference • What are the two modes in the vi editor? • Read Chapter 1, of the Horstmann text for next week.