general computer science for engineers cisc 106 lecture 26 dr. john cavazos computer and information...

Post on 21-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

General Computer General Computer Science Science

for Engineersfor EngineersCISC 106CISC 106

Lecture 26Lecture 26

Dr. John CavazosComputer and Information Sciences

04/24/2009

Lecture OverviewLecture OverviewIntroducing C++C++ vs. MATLABMore about C++

A programming languageDerived from a language called CUbiquitous Object Oriented

◦Easier to write large scale projects◦Reusability

High Performance

Supports data securityHelps code reuseAllows multiple functions/operators with same name

Large projectsSystems applicationsGraphicsData StructuresWant to speed up your scripts 

When not to use C++When not to use C++Small programsPrototyping (MATLAB, scripting

languages)Web applications (javascript)

C++ versus MATLABC++ versus MATLABMATLAB uses an interpreter

To run can just type and use matlab commands

C++ uses a compilerProgram converted to machine code

with compiler

C++ versus MATLABC++ versus MATLABMATLAB uses dynamic typing

Introduce new variables as neededType of variable discovered by use

C++ uses static typingVariables have to be introducedType is given when introduced

C++ Data TypesC++ Data Types

Must introduce variables before using“Double quotes” for stringsInput and output

int studentAge;

cout << “How old are you?”;cin >> studentAge;

 

Arrows “show the way” data if flowing

cout << … going out (output)cin >> … going in (input)

cout << “Student Age” << 20 << endl;

int i;float f;cin >> i;cin >> f;

#include <iostream>using namespace std;

int main(){ // display output cout << “Hello World\n”;}

 

$ CC –o helloworld helloworld.cc$ ./helloworldHello World$

top related