Computer Programming Dr. Fahad Computer Science Deptt.
Course Description This course provides the fundamental programming concepts. The emphasis will be on problem solving rather than just learning the programming language. Programming topics include control structures, functions, arrays, pointers, structures.
Intro to computer Brief Course outline C++ basics Selection and control structures User defined functions Mid Term Arrays Pointers Structures File handling Final Term Marking Distribution Quizzes 10% Assignments 5% Lab 15% Mid-Term 20% Project 10% Final 40% Total 100%
Recommended Books Deitel & Deitel, C++ How to Program, 5th Edition (or any latest) Robert Lafore, Object-Oriented Programming in C++, 3 rd /4 th Edition
requirements
Reference book
Contents Computer Hardware and Software Computer problems and problem solving Visual C++ environment First C++ program
Computer Hardware Input Processing Output
Input Devices
Output Devices
Processing
Memory Concepts Secondary Memory Hard disk, Floppy disk, CD/DVD Main memory/primary memory
Computer Organization Main memory vs. secondary memory. why ram and cache were introduced.
Computer Software is a collection of computer programs. e.g. Need for Speed, MS Office, Windows computer program vs. computer software
Types of Softwares System Softwares Application softwares Embedded softwares Scientific and Engineering softwares Business softwares
Number system Binary (1, 0) Octal (0-7) Decimal (0-9) Hexadecimal (0-9, A-F)
Bits & Bytes A bit is a single numeric value either 1 or 0. that encodes a single unit of digital information. A byte is a sequence of bits. 8bits=1byte.
Computer File
Networks Connected nodes/ devices for the purpose of sharing information and resources.
Communicate with computer Computer understands its own machine language (combo of 0s and 1s). Language instructs computer to perform tasks. We need to understand computer s language to communicate with it and to make it perform our desired functions. So we have.
High-Level & Low Level Languages Difference: It is easily understandable to human or not. High Level Language means the language is easily understandable, Uses English-like language Low Level Language means the language is more to a machine language than human understandable language.
Compiler is a computer program or set of programs that transforms source code to object code. Cross-Compiler DeCompiler Language ReWriter
Compilation process
Lexical analysis
Programming and Problem solving Algorithm A set of steps for solving a particular problem. Algorithms can be expressed in any language. From natural language (English or German) to high level language (VB, C++). Program An algorithm expressed in a language that computer can understand.
Program Design Process Problem solving phase Implementation phase
Program Errors Syntax errors Grammar/syntax error Run time errors during execution indicate bugs example: un-handled exceptions, memory overrun. logical errors Bug in program that causes program to operate incorrectly, but not terminate.
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { } cout << "Hello World!";
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A simple C++ Program #include <iostream> void main (void) { cout << Hello Word ; }
A simple C++ Program #include <iostream> void main (void) { cout << "Hello World!"; }
A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include <iostream> using namespace std; int main() { cout << "!!!Hello World!!!" << endl; return 0; } Insertion operator Ends executions of main() which ends program Insertion statement Comments Provides simple access Function
Output