Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.

Slides:



Advertisements
Similar presentations
Objectives You should be able to describe: Introduction to Programming
Advertisements

Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
COSC 120 Computer Programming
An Overview of Object-Oriented Programming and C++
Three types of computer languages
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Chapter 2: Input, Processing, and Output
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
PRE-PROGRAMMING PHASE
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
COMPUTER SCIENCE I C++ INTRODUCTION
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
A Review of Programming and C++
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Programming Lifecycle
Programming With C.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Syntax and Semantics, and the Program Development Process ROBERT REAVES.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Lecture 10: Modular Programming (functions) B Burlingame 13 April 2015.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Learners Support Publications Introduction to C++
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Basics of Computer A Computer is Electronic device that can
User-Written Functions
Chapter 1.2 Introduction to C++ Programming
Completing the Problem-Solving Process
C Programming Hardik H. Maheta.
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Chapter 1. Introduction to Computers and Programming
Chapter 1: An Overview of Computers and Programming Languages
Introduction to C++ Programming
Chapter 2 - Introduction to C Programming
Programming Funamental slides
1) C program development 2) Selection structure
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Presentation transcript:

Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016

Algorithms’ Operations Algorithmscanbeconstructedby the following operations: Sequential Operation Each step is performed in the order in which it is written. Conditional Operation Each operation is a control operations that allow us to alter the normal sequential flow of control in an algorithm. Iterative Operation Allow the repetition of a block of statements according to a condition. Iteration is sometimes called looping.

Quiz 3 Question:  Write a pseudo-code & draw flowchart that will calculate the sum for the first 100 odd integers.

Pseudo-codeFlowchart set count to 1 set value of sum to 0 while (count < 100) set sum to sum + count set count to count + 2 endwhile print value of sum Illustrated in the following slide Solution of Quiz 3

Solution of Quiz 3 (Cont…) Start Count =1 Sum=0 Sum=sum+count Count=count+2 Count<100 Print Sum End No Yes

Assignment III Write a pseudo-code and draw a flowchart for the following: 1. Calculate the salary of 100 workers in a factory.

Pseudo-codeFlowchart set value of count to 1 L: if (count > 100) then endwhile get values for name, wage, and hours set pay to wage * hours print value of name, pay set count to count + 1 goto L Illustrated in the following slide Assignments’ III Solution

Assignments’ III Solution (Cont…)

Task of Programming When you write programs, you write program statements that are instructions that are similar to English-language sentences. The statements you write in a programming language must be subsequently translated into machine language. Machine language is the language that computers can understand; it consists of 1s and 0s. A translator program (called either a compiler or an interpreter) checks your program for syntax errors. If there are no errors, the translator changes your written program statements into machine language. Therefore, syntax errors are not a big problem; you always have an opportunity to fix them.

Task of Programming (Cont…) A logical error occurs when you use a statement that, although syntactically correct, doesn’t do what you intended. Finding logical errors is much more time consuming for a programmer than finding syntax errors.

Programming Universals All programming languages provide methods for directing output and methods for sending input. All programming languages provide a way to name locations in computer memory. These locations are commonly called variables. Each variable have a data type which define the type of data to be store in this location. Example: int(0, 1, 2, 3), float(1.5, 2.3), char(a, b, c).

Cin Function

Cout Function

People and Programs User: an individual who runs, or executes, a program. Programmer: an individual who creates, or writes, a program.

Programming Language The selected programming language for this course is C++. C++ evolved from C. C++ designed by Bjarne Stroustrup at Bell Laboratories in early 1980s. C++ programs were not always portable from one compiler to another. In mid-1998, ANSI/ISO C++ language standards were approved.

General form of a C++ Program // Program description #include directives int main() { constant declarations variable declarations executable statements return 0; } Header for main function States… data type for the return value identifier for function list of arguments between parenthesis (none for this function) Braces enclose the body of the function They represent the start and end of the function Declarations and statements Main body of function (or main part) “//” represents the start of a comment All (almost) declarations and Statements end with a semi-colon “;”

Comments Comments appear in green in Visual C++. Comments are explanatory notes; they are ignored by the compiler. These remarks are useful to later program users because they might help explain the intent of a particular statement or the purpose of the entire program. There are two ways to include comments in a program: A line comment begins with two slashes (//) and continues to the end of the line on which it is placed. A block comment begins with a single slash and an asterisk (/*) and ends with an asterisk and a slash (*/); it might be contained on a single line or continued across many lines.

C++ Compiler Directives Compiler directives appear in blue in Visual C++. Header files are files that contain predefined values and routines, such as sqrt( ). In order for your C++ program to use these predefined routines, you must include a preprocessor directive, a statement that tells the compiler what to do before compiling the program. In C++, all preprocessor directives begin with a pound sign (#), which is also called an octothorp. The #include directive tells the compiler to include some already existing C++ code in your program.