COMP 102 Programming Fundamentals I Presented by : Timture Choi COMP102 Lab 011.

Slides:



Advertisements
Similar presentations
1 C++ Syntax and Semantics The Development Process.
Advertisements

Chapter 7: User-Defined Functions II
Structure of a C program
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
C++ Basics. COMP104 C++ Basics / Slide 2 Introduction to C++ * C++ is a programming language for manipulating numbers and user-defined objects. * C++
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.
Basic Elements of C++ Chapter 2.
Programming Introduction to C++.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
CPS120: Introduction to Computer Science Lecture 8.
Introduction to C++ Programming Introduction to C++ l C is a programming language developed in the 1970's alongside the UNIX operating system. l C provides.
UniMAP Sem2-08/09 DKT121: Fundamental of Computer Programming1 Introduction to C – Part 2.
C Tokens Identifiers Keywords Constants Operators Special symbols.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
CPS120: Introduction to Computer Science
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
Introduction to C++ // Program description #include directives int main() { constant declarations variable declarations executable statements return.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
UniMAP Sem1-07/08EKT120: Computer Programming1 Week2.
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Introduction to C++ Programming COMP102 Prog. Fundamentals I:Introduction to C++ / Slide 2 Introduction to C++ l C is a programming language developed.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
Introduction to Programming
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Lecture 3 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout from Lecture 1 Background.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
CPS120: Introduction to Computer Science Variables and Constants.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
Simple Data Types Chapter Constants Revisited t Three reasons to use constants –Constant is recognizable –Compiler prevents changes in value.
UNIMAP Sem2-07/08EKT120: Computer Programming1 Week 2 – Introduction to Programming.
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter # 2 Part 2 Programs And data
Chapter Topics The Basics of a C++ Program Data Types
Chapter 2 Introduction to C++ Programming
Data Types, Variables & Arithmetic
BASIC ELEMENTS OF A COMPUTER PROGRAM
Variable Declarations
Variables A variable is a placeholder for a value. It is a named memory location where that value is stored. Use the name of a variable to access or update.
Basic Elements of C++.
Revision Lecture
C Basics.
Mr. Shaikh Amjad R. Asst. Prof in Dept. of Computer Sci. Mrs. K. S
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Variables ,Data Types and Constants
Basic Elements of C++ Chapter 2.
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Chapter # 2 Part 2 Programs And data
Chapter 2: Java Fundamentals
C++ Programming Lecture 3 C++ Basics – Part I
Programming Introduction to C++.
C++ Programming Basics
C Language B. DHIVYA 17PCA140 II MCA.
Variables and Constants
Getting Started With Coding
Presentation transcript:

COMP 102 Programming Fundamentals I Presented by : Timture Choi COMP102 Lab 011

Introduction to C++ C++ Extension of C Supports OO programming Free-format language General form Comment Include necessary header files “main()” function COMP102 Lab 012

Comments Provides explanatory notes Purpose of the program/each function Usage of each variable Appear in green in VC++ 1. Single line comments // 2. Multiple line comments /* … */ COMP102 Lab 013

Compiler Directives Appear in blue in VC++ Import the required library in program Pre-defined #include E.g., User-defined #include “xxx.h” COMP102 Lab 014

“main()” Function Start of the program Variables/constant declaration Must be declared before used Identifier  Name for variables/constant/function  Should not be a keyword  Case sensitive  Start with letter Statements Deal with user input/output Specific calculation COMP102 Lab 015

Programming Style Free-format language Increase writability  How easily a language can be used to write programs Decrease readability  Measures how easy it can be understood Note: Write comments for both variables and functions Use meaningful variable names Only one statement for each line COMP102 Lab 016

Declarations Allocation Reserves memory to store constants and variables Deallocation Releases storage of constants and variables from memory Binding Associates the constants/variables with memory location COMP102 Lab 017

Declarations Constant Cannot be changed throughout the program Syntax:  const = ; const: keyword E.g.  const double pi=3.14, gravity=9.8; COMP102 Lab 018

Declarations Variable Can be changed during program execution Note: will not be initialized automatically  Better to initialize when declared Syntax:  ; , ;  = ; COMP102 Lab 019

Data Type void no value and operation int Integer 32 bits (4 bytes) Float Floating point 32 bits (4 bytes) Double 64 bits (8 bytes) char Character bool Either true/false COMP102 Lab 0110

Data Type Note: Precision Data size  Depend on design/compiler of the language  Bytes/Bits  Overflow/Underflow  Affect program size Data range  Signed/Unsigned Signed bit COMP102 Lab 0111

SUMMARY By the end of this lab, you should be able to: Understand the general form of a program  Comments  Compiler directives  “main()” function  Keyword and identifier Defined and Initialized  Constants  Variables With appropriate data types COMP102 Lab 0112