Presentation is loading. Please wait.

Presentation is loading. Please wait.

Preston University, Islamabad Campus

Similar presentations


Presentation on theme: "Preston University, Islamabad Campus"— Presentation transcript:

1 Preston University, Islamabad Campus
Programming in C++ Preston University, Islamabad Campus

2 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.

3 Class Introduction Name Why did you chose the Current Field?

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

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

6 The Turbo C Programming Environment
Chapter 1

7 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

8 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

9 Introduction to C Language
C, 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.

10 Turbo C++ Environment Turbo C++ Development Systems
The Integrated Development Environment(IDE) Screen Display with windows Pull-down Menus Command Line Dos

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

12 Sub Directories BIN INCLUDE LIB So on

13 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

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

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

16 Program Execution Life Cycle

17 Compiler\Interpreter
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.

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

19 Structure of C++ Program
Three Main Parts Preprocessor Directories The main() Function C++ Statements #include<stdio.h> void main() { printf(“Hello World”); }

20 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

21 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… }

22 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.

23 IDE Environment

24 New File

25 Save File .cpp for C++ Program .c For C Program

26 C++ Program

27 Compile (Alt+F9)

28 Make\Link (F9)

29 Run (Ctrl+F9)

30 User Window

31 Program Error

32 Debugging

33 Exit IDE

34 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”); I Love Pakistan \t Tab printf(“A \t B”); A B \\ Print backslash printf(“C:\\TC”); C:\TC

35 Print Message printf in C printf(“This is number two: 2”);
printf(“This is number two : %d”,2); %d – decimal %c – character %s – String

36 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”); }

37 LAB Work Write a program that generate following output
Mr. Green is 42, Mr. Brown is 48. Write a program that print the phrase a, b and c are all letters. Use character constants to represent the letter.


Download ppt "Preston University, Islamabad Campus"

Similar presentations


Ads by Google