660 likes | 778 Views
Lecture 5+6 Introduction to computer & programming. MS SADIA EJAZ CS DEPARTMENT. The Internet. It is a huge network of computers, which links many different types of computers all over the world.
E N D
Lecture 5+6 Introduction to computer & programming MS SADIA EJAZ CS DEPARTMENT MS Sadia Ejaz CIIT ATTOCK
The Internet It is a huge network of computers, which links many different types of computers all over the world. It is a network of networks, which share a common mechanism for addressing (identifying) computers, and a common set of communication protocols for communication between two computers on the network. MS Sadia Ejaz CIIT ATTOCK 2
The Internet’s Major Services The World Wide Web Electronic mail News File Transfer Protocol Chat Instant Messaging Online- Services Peer-to-Peer Services MS Sadia Ejaz CIIT ATTOCK 3
The World Wide Web The World Wide Web (commonly shortened to the Web) is a system of interlinked hypertext documents accessed via the Internet. With a Web browser, a user views Web pages that may contain text, images, videos, and other multimedia and navigates between them using hyperlinks. MS Sadia Ejaz CIIT ATTOCK 4
Web Search Engine A Web search engine is a search engine designed to search for information on the World Wide Web. A search engine lets you search for information by typing one or more words. The engine then displays a list of Web pages that contain information related to your words. Example: Google search engine MS Sadia Ejaz CIIT ATTOCK 5
E - Mail Electronic mail, often abbreviated to e-mail, is a store-and-forward method of writing, sending, receiving and saving messages over electronic communication systems. 6
Programming Language Generations • Machine languages: first generation • Assembly languages: second generation • Higher-level languages: third generation (3GLs) MS Sadia Ejaz CIIT ATTOCK
Fading Third-Generation Languages • FORTRAN (FORmula TRANslator) • COBOL (COmmon Business Oriented Language) • BASIC (Beginner’s All-Purpose Symbolic Instruction Code) • Pascal MS Sadia Ejaz CIIT ATTOCK
Thriving Third-Generation Languages • C • C++ • Java • ActiveX MS Sadia Ejaz CIIT ATTOCK
Fourth-Generation Languages (4GLs) • Builds programs with a front end, which is an interface that hides much of the program from the user • Provides prototypes, which are samples of the finished programs MS Sadia Ejaz CIIT ATTOCK
Examples of Fourth-Generation Languages • Visual Basic (VB) • VisualAge • Authoring environments MS Sadia Ejaz CIIT ATTOCK
Fifth-Generation Languages (5GLs) • Advanced authoring environments considered by some to be 5GLs MS Sadia Ejaz CIIT ATTOCK
World Wide Web Development Languages • HyperText Markup Language (HTML) • Extensible Markup Language (XML) • Wireless Markup Language (WML) • Dreamweaver • Flash • Director MS Sadia Ejaz CIIT ATTOCK
Systems Development Life Cycle for Programming • Phase 1: Needs analysis • Phase 2: Program design • Phase 3: Development (also called coding) • Phase 4: Implementation • Phase 5: Maintenance MS Sadia Ejaz CIIT ATTOCK
Why We Do Programming ? • For solving problems • Computers are used as a tool to solve complex problems by developing computer programs that provide the solution of the problems. • Example: • Program : For adding 2 numbers, i.e 3 and 5 • Solution: A computer program will be developed for their addition. MS Sadia Ejaz CIIT ATTOCK
Problem-Solving Techniques • Program • Algorithm • Pseudo Code • Flowchart , etc. MS Sadia Ejaz CIIT ATTOCK
Program • A set of instructions that tells a computer what to do is called program. • Computer programs are written in programming languages. • A person who develops a program is called programmer. MS Sadia Ejaz CIIT ATTOCK
Algorithms • It is a step-by-step procedure to solve a problem. • Properties of Algorithm • The given problem should be broken down into simple and meaningful steps. • The steps should be numbered sequentially. • The steps should be descriptive and written in simple English. MS Sadia Ejaz CIIT ATTOCK
Pseudo Code / Pseudo Language • Algorithms are written in a language, which is similar to simple English , which is known as pseudo language. • The purpose of using pseudo code is that it may be easier for humans to read than conventional programming languages. • No standard for pseudo code syntax exists, as a program in pseudo code is not an executable program. MS Sadia Ejaz CIIT ATTOCK
Parts of Program Development • Two main parts • Logic Design • Coding MS Sadia Ejaz CIIT ATTOCK
Logic Design • Logic of the program is designed by specifying different steps required and the sequence of these steps to solve the problem. MS Sadia Ejaz CIIT ATTOCK
Coding • The algorithm is converted into a program. MS Sadia Ejaz CIIT ATTOCK
Example • Algorithm for calculating and displaying the sum of two numbers, • Input A, B • Total / Sum A + B • Display Total • Exit MS Sadia Ejaz CIIT ATTOCK
Advantages of Algorithms • Reduced Complexity • Increased Flexibility • Ease of Understanding MS Sadia Ejaz CIIT ATTOCK
Flowchart • It is combination of two words i.e. flow and chart. • Flowchart is a graphical representation of an algorithm. • Chart consists of different symbols to display information about any program. • Flow indicates the direction of processing that takes place in the program. • It is used to show all the steps of an algorithm in a sequence. MS Sadia Ejaz CIIT ATTOCK
Flowchart (contd.) MS Sadia Ejaz CIIT ATTOCK
Uses of Logic Flowchart • It is used to represent an algorithm in simple graphical manner. • It is used to show the steps of an algorithm in an easy way. • It is used to understand the flow of the program. • It is used to improve the logic for solving a problem. • Programs can be reviewed and debugged easily. MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols • Input/Output Parallelogram symbol is used to represent an input or output step. Input statement is used to get input from the user. The output statement is used to display a message to the use or to display a value. Input Output MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols (contd.) • Process Rectangle symbol is used to represent a process step. MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols (contd.) • Selection Diamond symbol is used to represent a selection step. MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols (contd.) • Start/End Oval symbol is used to represent the start or end of the flowchart. End Start MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols (contd.) • ConnectorIndicates that the flow continues where a matching symbol (containing the same letter) has been placed. MS Sadia Ejaz CIIT ATTOCK
Basic Flowchart Symbols (contd.) • Flow LineLines indicate the sequence of steps and the direction of flow. MS Sadia Ejaz CIIT ATTOCK
Example Start Input A, B Sum = A+B Display Sum End MS Sadia Ejaz CIIT ATTOCK
Difference Between Pseudo Code and Flowchart MS Sadia Ejaz CIIT ATTOCK
Program Development Process • A programmer has to go through the following stages to develop a computer program: • Defining and Analyzing the Problem. • Designing the Algorithm • Coding or Writing the Program • Test Execution • Debugging • Final Documentation MS Sadia Ejaz CIIT ATTOCK
Integrated Development Environment (IDE) • Editor • Compilers • Debugger • Linkers • Loaders MS Sadia Ejaz CIIT ATTOCK
Program is created in the editor and stored on disk. Disk Preprocessor program processes the code. Disk Compiler creates object code and storesit on disk. Disk Compiler Linker links the object code with the libraries Disk Primary Memory Loader Loader puts program in memory. Disk Primary Memory CPU takes each instruction and executes it, possibly storing new data values as the program executes. CPU Preprocessor Linker Editor . . . . . . . . . . . . MS Sadia Ejaz CIIT ATTOCK
Tools of the trade • Editor • First of all we need a tool for writing the code of a program. For this purpose we used Editors in which we write our code. MS Sadia Ejaz CIIT ATTOCK
Debugger It is used to debug the program. MS Sadia Ejaz CIIT ATTOCK
Linker Most of the time our program is using different routines and functions that are located in different files, hence it needs the executable code of those routines/functions. Linker is a tool which performs this job, it checks our program and includes all those routines or functions which we are using in our program to make a standalone executable code and this process is called Linking. MS Sadia Ejaz CIIT ATTOCK
Loader Another process which is needed to load the program into memory and then instruct the processor to start the execution of the program from the first instruction (the starting point of every C program is from the main function). This processor is known as loader. Linker and loaders are the part of development environment. These are part of system software. MS Sadia Ejaz CIIT ATTOCK
Debugging in Turbo C++ An error in a computer program is known as bug. The process of finding and removing bugs is known as debugging. MS Sadia Ejaz CIIT ATTOCK
Types of Errors Syntax Errors Logical Errors Run-Time Errors MS Sadia Ejaz CIIT ATTOCK
Syntax Errors It is a type of error that occurs when an invalid statement is written in program. MS Sadia Ejaz CIIT ATTOCK
Logical Errors It is a type of error that occurs due to poor logic of the programmer. MS Sadia Ejaz CIIT ATTOCK
Run-Time Errors It is a type of error that occurs during the execution of program. MS Sadia Ejaz CIIT ATTOCK
C++ Statement • The statement of the program are writen under the main() function between the curely bracket{}. • These statement are the body of program • Each statement of the c++ ends with a semicolon(;) • C++ is a case sensitive language • The c++ statement are normally written in lowercase letters but in some exceptional but in some exceptional cases, these can also be written in upper case MS Sadia Ejaz CIIT ATTOCK
keyword • The words that are used by the language for special purpose are called keywords • e.g. in c++ program, the word main is used to indicate the starting of program, include is used to header files, int to declare an integer data type • All these words are keyword of c++ • The keyword cannot be used as variable names in program MS Sadia Ejaz CIIT ATTOCK
Identifiers The identifiers are the names used to represent variable, constants, types, functions and labels in the program. An identifier in C++ may consist of 31 characters. MS Sadia Ejaz CIIT ATTOCK