Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

Introduction to Programming Lecture 2. Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.6 Machine Languages, Assembly Languages,
Introduction Kingdom of Saudi Arabia Shaqra University
COSC 120 Computer Programming
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Three types of computer languages
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
CS 117 Section 2 + KNET Computer accounts – ed to KNET students –Change password Homework 1 Lab Tutors –In lab for next 2 weeks –Will help you with.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Chapter 01: Introduction to Computer Programming
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
COMPUTER SCIENCE I C++ INTRODUCTION
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Input & Output: Console
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice:
Creating your first C++ program
1 Problem Solving with C++ The Object of Programming Walter Savitch Chapter 1 Introduction to Computers and C++ Programming Slides by David B. Teague,
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Week 1 Algorithmization and Programming Languages.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Chapter 2 part #1 C++ Program Structure
Typical C++ Environment and Library Introduction Speaker : Wei-Lu Lin Advisor : Ku-Yaw Chang 2012/10/14.
Hardware and Software Programming. COMP104 Lecture 2 / Slide 2 Hardware and Software l Why should we bother with hardware, while we are having a programming.
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan 2.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Week 1 Lecture 2SE1SA51 Introducing C SE1SA5 Sue Walmsley.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Introduction to C Programming
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Programming Fundamental
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1: Introduction to computers and C++ Programming
Chapter 1.2 Introduction to C++ Programming
CSC201: Computer Programming
CS-103 COMPUTER PROGRAMMING
Computer Engineering 1nd Semester
Computer Science I CSC 135.
1.13 The Key Software Trend: Object Technology
Programs written in C and C++ can run on many different computers
Capitolo 1 – Introduction C++ Programming
Introduction to C Programming
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2

2 Basics of C++ Environment Phases of C++ Programs Edit Preprocess Compile Link Load Execute Loader Primary Memory Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler Compiler creates object code and stores it on disk. Linker links the object code with the libraries, creates a.out and stores it on disk Editor Preprocessor Linker CPU Primary Memory Disk

3 Programming environment MSVC (windows) GCC (Linux, Unix) Many other compilers are available: Ex. Borland c++ Eclips What is IDE integrated development environment : is a software application that provides comprehensive facilities to computer programmers for software development

4 Using MSVC

5

6

7

8

9

10

11

12

13

14

15

16

17 Linux & Unix gcc command, and g ++ is the C++ compiler, while cc and CC are the Sun C and C++ It works on both Linux & Unix GCC step by step 1. Write your program on one of the text editors example ( vi or emacs ) 2. Save your file as name.cpp where name is the name of your file 3. Use one of the following ways to compile your program.

18 Compile then Build g++ -c hello.cpp // compile g++ hello.o -o hello // build

19 The simple way The standard way to compile this program is with the command g++ hello.cpp -o hello This command compiles hello.cpp into an executable program named "hello" that you run by typing 'hello' at the command line. It does nothing more than print the word "hello" on the screen

20 Compiling a program with multiple source files If the source code is in several files, say "file1.cpp" and "file2.", then they can be compiled into an executable program named "myprog" using the following command: g++ file1.C file2.C -o myprog

21 Compile then Build multiple files g++ -c file1.cpp g++ -c file2.cpp g++ file1.o file2.o -o myprog

22 Basics of a Typical C++ Environment Input/output cin Standard input stream Normally keyboard cout Standard output stream Normally computer screen cerr Standard error stream Display error messages

23 Ways to format the program

24 Ways to format the program

25 Variables and Data Types A place in Memory To hold an information that a user use. Deceleration SpaceOccupied VariableName;

26 C++’ Names The name of a variable: Starts with an underscore “_” or a letter, lowercase or uppercase, e.g. _Students, pRice Can include letters, underscore, or digits. Examples are: keyboard, total_grade, _Score_Side1 Cannot include special characters such as !, %, ], or $ Cannot include an empty space Cannot be any of the reserved words Should not be longer than 32 characters (although allowed)

27 Reserved Words

28 Variables and Their Data Types The amount of memory space necessary to store a variable is also referred to as a data type.

29

30 Variables and Their Data Types char 8 bits short int A group of 16 contiguous bitsĀÚranges from – to

31 Example

32 Practice -- what is the o/p

33 Practice -- what is the o/p

34 O/P

35 Representing a Double-Word Double-word combines 4 bytes, or 8 nibbles, or 32 bits. The bits, counted from right to left, start at 0 and end at 31.

36 What are constants? const PI = 3.14; #define PI 3.14