Asst.Prof.Dr. Tayfun ÖZGÜR

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
Advertisements

C++ Basics Variables, Identifiers, Assignments, Input/Output.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Structure of a C program
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Data Types.
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.
KEAN UNIVERSITY Visual C++ Dr. K. Shahrabi. Developer studio Is a self-contain environment for creating, compiling, linking and testing windows program.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
 Programming Languages  First Generation Languages (Machine Language)  We Actually have to do a few things. First we have to find the operating code,
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
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.
Week 1 Algorithmization and Programming Languages.
C++ Programming, Namiq Sultan1 Chapter 2 Introduction to C++ Namiq Sultan University of Duhok Department of Electrical and Computer Engineerin Reference:
COMPUTER PROGRAMMING. variable What is variable? a portion of memory to store a determined value. Each variable needs an identifier that distinguishes.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
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.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
Basic Types, Variables, Literals, Constants. What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet)
C++ Lesson 1.
Variables, Identifiers, Assignments, Input/Output
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Working with Java.
Chapter 1.2 Introduction to C++ Programming
Basics (Variables, Assignments, I/O)
Chapter 1.2 Introduction to C++ Programming
Data types Data types Basic types
University of Central Florida COP 3330 Object Oriented Programming
Compiler Construction
Basics (Variables, Assignments, I/O)
CMSC 104, Section 4 Richard Chang
بسم الله الرحمن الرحيم.
Reserved Words.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Basics (Variables, Assignments, I/O)
null, true, and false are also reserved.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C++ Basics.
פרטים נוספים בסילבוס של הקורס
Introduction to Java Programming
درس برنامه‌سازي کامپيوتر
Variables in C Topics Naming Variables Declaring Variables
Basics of ‘C’.
Chapter 1: Computer Systems
Keywords.
Govt. Polytechnic,Dhangar
Variables, Identifiers, Assignments, Input/Output
Chapter 2: Java Fundamentals
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Variables in C Declaring , Naming, and Using Variables.
Focus of the Course Object-Oriented Software Development
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
Chap 2. Identifiers, Keywords, and Types
Module 2 Variables, Data Types and Arithmetic
C Language B. DHIVYA 17PCA140 II MCA.
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Asst.Prof.Dr. Tayfun ÖZGÜR ME 198 Computer Programming Asst.Prof.Dr. Tayfun ÖZGÜR

What is C++ C++ is a general purpose object oriented programming language. It is considered to be an intermediate level language, as it encapsulates both high and low level language features. Initially, the language was called 'C with classes’ as it had all properties of C language with an additional concept of 'classes’. However, it was renamed to C++ in 1983. It is pronounced "C-Plus-Plus."

A sequence of instructions is called an algorithm A sequence of instructions is called an algorithm. Algorithms are a fundamental part of computing. There are two commonly used tools to help to document program logic (the algorithm). These are flowcharts and Pseudocode. Generally, flowcharts work well for small problems but Pseudocode is used for larger problems.

Some of the common symbols used in flowcharts are shown below:

below program computes the sum, average and product of three numbers:

BASICS OF C++ Structure of a program

The Program #1 example has the following elements:   Comments, indicated by the // prefix A preprocessor #include directive A using namespace directive A function heading: int main() A function body, delimited by { and } A statement that uses the C++ cout facility to display a message A return statement to terminate the main() function

Variables, Data Types

A valid identifier is a sequence of one or more letters, digits or underscore characters (_). Neither spaces nor punctuation marks or symbols can be part of an identifier. Only letters, digits and single underscore characters are valid. In addition, variable identifiers always have to begin with a letter. They can also begin with an underline character (_ ), but in some cases these may be reserved for compiler specific keywords or external identifiers, as well as identifiers containing two successive underscore characters anywhere. In no case they can begin with a digit. Another rule that you have to consider when inventing your own identifiers is that they cannot match any keyword of the C++ language nor your compiler's specific ones, which are reserved keywords. The standard reserved keywords are: asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto, if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while , and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq

Very important: The C++ language is a "case sensitive" language Very important: The C++ language is a "case sensitive" language. That means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters. Thus, for example, the RESULT variable is not the same as the result variable or the Result variable. These are three different variable identifiers.

Fundamental data types Name Description Size* Range* char Character or small integer. 1byte signed: -128 to 127 unsigned: 0 to 255 short int (short) Short Integer. 2bytes signed: -32768 to 32767 unsigned: 0 to 65535 int Integer. 4bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 long int (long) Long integer. bool Boolean value. It can take one of two values: true or false. true or false float Floating point number. +/- 3.4e +/- 38 (~7 digits) double Double precision floating point number. 8bytes +/- 1.7e +/- 308 (~15 digits) long double Long double precision floating point number. wchar_t Wide character. 2 or 4 bytes 1 wide character

Declaration of variables

Do not worry if something else than the variable declarations themselves looks a bit strange to you. You will see the rest in detail in coming sections