+ All Categories
Home > Documents > Preston University, Islamabad Campus

Preston University, Islamabad Campus

Date post: 18-Jan-2018
Category:
Upload: stephanie-simmons
View: 229 times
Download: 0 times
Share this document with a friend
Description:
Lecturer’s Introduction Senior Executive IT (Middleware and Provisioning) in Ufone Working in IT Industry (Software Development) since 2007 MS in Software Engineering from NUST in 2012 BS in Computer and Information Sciences from PIEAS in 2007 Designed / Developed Multiple Systems / Optimized Business Flows for Internal IT Customers and External Business Customers including Complete In House built CRM Enhancements, Provisioning System, Reporting Modules.
37
Programming in C++ Preston University, Islamabad Campus
Transcript
Page 1: Preston University, Islamabad Campus

Programming in C++Preston University, Islamabad

Campus

Page 2: Preston University, Islamabad Campus

Lecturer’s Introduction

• Senior Executive IT (Middleware and Provisioning) in Ufone• Working in IT Industry (Software Development) since 2007

• MS in Software Engineering from NUST in 2012• BS in Computer and Information Sciences from PIEAS in 2007

• Designed / Developed Multiple Systems / Optimized Business Flows for Internal IT Customers and External Business Customers including Complete In House built CRM Enhancements, Provisioning System, Reporting Modules.

Page 3: Preston University, Islamabad Campus

Class Introduction

• Name• Why did you chose the Current Field?

Page 4: Preston University, Islamabad Campus

Book

• Turbo C Programming for the PC and Turbo C++: Revised Edition by Robert Lafore: SAMS Publishing

Page 5: Preston University, Islamabad Campus

Grading Mechanism

• Assignments / Projects: 10 Marks• Quizzes: 10 Marks• Class Participation / Attendance: 5 marks• Mid Term: 25 Marks• Final: 50 Marks

Page 6: Preston University, Islamabad Campus

The Turbo C Programming Environment

Chapter 1

Page 7: Preston University, Islamabad Campus

• Computer science deals with the theoretical foundations of information and computation, together with practical techniques for the implementation and application of these foundations

• Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs

• Technology is changing everyday in this field– Necessary to get up to date on the regular bases– Big competition factor present in the field of Software

development

Page 8: Preston University, Islamabad Campus

Computer Language• A computer language is a set of rules and conversions used to convey the

information to a computer.• There are three types of computer language:

– Machine Language: The native tongue of a computer is the machine language. Each Machine Language instruction is a binary string of 0’s and 1’s that specifies an operation and identifies the memory cells involved in that operation.

– Low Level Language: In the low level language, Machine Language is still used by the computer as it processes data, but Low level Language software first translate the specific operation symbol onto machine language equivalent. e.g. Assembly Language

– High Level Language: High Level Language is a programming Language where an instruction resembles everyday language. Instructions are given to computer by using conventional letters, symbols or English text rather than by using 1’s and 0’s code that the computer understand.e.g. Basic and Pascal etc

Page 9: Preston University, Islamabad Campus

Introduction to C LanguageC, a high-level language programming language was developed in early 1970s by Dennis Ritchie at Bell Laboratories. Over the years, the power and flexibility of C, together with the availability of high quality C compilers for computers of all sizes, have made it a popular language in industry for a wide variety of applications.

• Why use C Language?– C is the most popular PC programming language.– C is unique in programming language in that it provides the convenience of a high

level language such as Basic or Pascal, but at the same time allows much closer control of a computer's hardware and peripherals, as the assembly language does.

– C compilers can generates amazingly fast code.– C Language is a well-structured and modular language. Its syntax makes it easy to

write programs that are modular and therefore they are easy to understand and maintain.

– C Language is portable: i.e it is easier to convert a C program to run on a different machine than it is to convert programs written in most other languages.

– C Language IDE is more user-friendly then most other languages.

Page 10: Preston University, Islamabad Campus

Turbo C++ Environment

• Turbo C++ Development Systems– The Integrated Development Environment(IDE)

• Screen Display with windows • Pull-down Menus

– Command Line• Dos

Page 11: Preston University, Islamabad Campus

Installation Program• Extract Turbo C++ files• Install the software DOSBox ver 0.74 (TC Installer)• 6MB HD Space Required

Page 12: Preston University, Islamabad Campus

• Sub Directories– BIN– INCLUDE– LIB– So on

Page 13: Preston University, Islamabad Campus

BIN

• Executable File • TC.exe (Place IDE on Screen)

• TCC – Command – line compiler• TLINK – Command-line Linker• MAKE – File-management Program• CPP – Preprocessor Utility• TZIP – Library File Manager• etc

Page 14: Preston University, Islamabad Campus

LIB

• Library Files• Precompiled routines for performing specific Tasks• E.g. Math Libraries, Run Time Object Files

Page 15: Preston University, Islamabad Campus

INCLUDE

• Header Files• Contains definition of Library Files• .h extension• Added in to Program before compilation

Page 16: Preston University, Islamabad Campus

Program Execution Life Cycle

Page 17: Preston University, Islamabad Campus

Compiler\Interpreter

• Compiler– Spends some time evaluating the entire program and

then translates all the programming statements of a program into a machine language program, which is then executed at once.

• Interpreter – Translates interactively each programming statement

into an immediately usable machine language instruction. Although an interpreter slows down the execution speed of a program somewhat, it does not require extra steps to compile and link like a compiler.

Page 18: Preston University, Islamabad Campus

C\C++

• C++ is the Advance version of C• C is the Procedural Language• C++ is the Object Orient Programming Language

Page 19: Preston University, Islamabad Campus

Structure of C++ Program

• Three Main Parts– Preprocessor Directories– The main() Function– C++ Statements

#include<stdio.h>void main(){printf(“Hello World”);}

Page 20: Preston University, Islamabad Campus

Preprocessor Directories

• The instruction that are given to the compiler before the beginning of the actual program

• Also know as Compiler Directories• Consist Instructions for the compiler• Start with Number Sign #• Keywords “include” or “define”• E.g. Used to include Header files

Page 21: Preston University, Islamabad Campus

The main() Function

• Contain Main body of C++ Program• void before main() specifies that function will not return

a value• main(void) specifies that function takes no arguments

void main(void){ program statements…}

Page 22: Preston University, Islamabad Campus

C++ Statements

• Written under the main() function between the curly braces{} (Delimiters)

• Each statement end with semicolon(;) in C++• Case Sensitive Language• Contain Keyword/Reserved Words

– E.g. include, int , main etc.• Tokens

– Consists of variable names, keywords, constants, punctuation marks, operators etc.

Page 23: Preston University, Islamabad Campus

IDE Environment

Page 24: Preston University, Islamabad Campus

New File

Page 25: Preston University, Islamabad Campus

Save File

• .cpp for C++ Program• .c For C Program

Page 26: Preston University, Islamabad Campus

C++ Program

Page 27: Preston University, Islamabad Campus

Compile (Alt+F9)

Page 28: Preston University, Islamabad Campus

Make\Link (F9)

Page 29: Preston University, Islamabad Campus

Run (Ctrl+F9)

Page 30: Preston University, Islamabad Campus

User Window

Page 31: Preston University, Islamabad Campus

Program Error

Page 32: Preston University, Islamabad Campus

Debugging

Page 33: Preston University, Islamabad Campus

Exit IDE

Page 34: Preston University, Islamabad Campus

Escape Sequence

• Special non-printing characters to control printing on output device

• Combination of backslash ‘\’ and a code

Escape Sequence Explanation\n New line

printf(“I \n Love \n Pakistan”);ILovePakistan

\t Tab printf(“A \t B”);A B

\\ Print backslashprintf(“C:\\TC”);C:\TC

Page 35: Preston University, Islamabad Campus

Print Message

• printf in C– printf(“This is number two: 2”);– printf(“This is number two : %d”,2);

%d – decimal%c – character%s – String

Page 36: Preston University, Islamabad Campus

Activity

• After the source file C \ C++ program has been written, it must be– C_______– L_______– And E_______

• Output?– printf(“%s is %d million \n from the sun.”, “venus”,67);– printf(“ Path of Turbo C++ is: \n %s”,“C:\\TC”);– void main(void){printf(“%s\n%s\n%s”, “one”, “two”, “three”);}

Page 37: Preston University, Islamabad Campus

LAB Work

• Write a program that generate following outputMr. Green is 42,Mr. Brown is 48.

• Write a program that print the phrasea, b and c are all letters.Use character constants to represent the letter.


Recommended