comp104 notes

September 29, 2017 | Autor: Chen Zou | Categoría: Computer Science, Software Engineering, Programming Languages
Share Embed


Descripción

Class Test Date(s): Wednesday, 17/12/2014 Time: 10:00-12:00 Room: BROD-305

ELEC431 LECTURE INTRODUCTION TO C/C++

L1

Content What is C++  Why C++  Generation form and feature of C++  Programme style  Data type  I/O 

What is C++?  

C++ is a programming language. A computer program performs a specific task, and may interact with the user and the computer hardware.  Human work model:

 Computer

work model:

What is C++? 



The most popular programming languages:  Basic (Beginner All-purpose Symbolic Instructional Code)  C++ (an object-oriented language, based on C)  Fortran (FORmula TRANslation)  Java  Pascal (named for Blaise Pascal)  Visual Basic (Basic-like visual language developed by Microsoft)  C (developed by the designer of the B language) The most common versions of C++:  Microsoft VC++  Eclipse  g++ (for Unix machines)

Why C++? 

Bad News:  C++ is not easy to learn



Good News:  Lots of good-paying jobs for programmers because C++ is not easy to learn!  Java uses C++ syntax, it is easy to learn Java if you know C++.  Though C++ is not the easiest language (Basic and Pascal are easier), it is not the hardest either (Prolog and Assembly languages are really difficult!)

Who Uses C++?   

     

Computer makers such as Sun, SGI, IBM, and HP Airport Computer chip manufacturers like Motorola & Intel Software companies Banks Government Hospital Authority Telecommunications Universities

Most Important Feature of C++ 



Most important feature of C++: its strong and efficient support of both Structured Programming and Object-Oriented Programming. C++ runs on:  PC  Macintosh  Unix workstations (also, Unix versions of C++ are free!)  supercomputers

Computer Software Relationships User Interface Application Programs

User Interface

Operating System

User Basic Input and Output Services (BIOS) Interface • needed for a computer to boot up

Computer Hardware

Introduction to C++ 



 

C is a programming language developed in the 1970's alongside the UNIX operating system. C provides a comprehensive set of features for handling a wide variety of applications, such as systems development and scientific computation. C++ is an “extension” of the C language, in that most C programs are also C++ programs. C++, as opposed to C, supports “objectoriented programming.”

General form of a C++ program // Program description #include directives int main() { constant declarations variable declarations executable statements return 0; }

C++ keywords     

Keywords appear in blue in Visual C++. Each keyword has a predefined purpose in the language. Do not use keywords as variable and constant names!! Common keywords: bool, break, case, char, const, continue, do, default, double, else, extern, false, float, for, if, int, long, namespace, return, short, static, struct, switch, typedef, true, unsigned, void, while

Example – adding 2 numbers        

Peter: Hey Frank, I just learned how to add two numbers together. Frank: Cool! Peter : Give me the first number. Frank: 2. Peter : Ok, and give me the second number. Frank: 5. Peter : Ok, here's the answer: 2 + 5 = 7. Frank: Wow! You are amazing!



after Frank says “2”, Peter has to keep this number in his mind.



after Frank says “5”, Peter also needs to keep this number in his mind. First number: 2

Second number: 5

Sum:

7

The Corresponding C++ Program #include using namespace std; int main() { int first, second, sum; cout
Lihat lebih banyak...

Comentarios

Copyright © 2017 DATOSPDF Inc.