C++ Basics.

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.
Types and Variables. Computer Programming 2 C++ in one page!
Structure of a C program
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.
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 (
Syntax of C Programming Language #Lesson 2 Sen Zhang.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
System development with Java Lecture 2. Rina Errors A program can have three types of errors: Syntax and semantic errors – called.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
Five Tips to Success. Work hard Try more exercises and more practice.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
C++ Programming, Namiq Sultan1 Chapter 2 Introduction to C++ Namiq Sultan University of Duhok Department of Electrical and Computer Engineerin Reference:
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
Characters and tokens Characters are the basic building blocks in C program, equivalent to ‘letters’ in English language Includes every printable character.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
COMPUTER PROGRAMMING. variable What is variable? a portion of memory to store a determined value. Each variable needs an identifier that distinguishes.
1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.Semantic © In this session we will.
What is C? C is a programming language. It was developed in 1972 USA. It was designed and written by a man named dennis ritchie. C is the base for all.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
C++ Basics Tutorial 5 Constants. Topics Covered Literal Constants Defined Constants Declared Constants.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Topics to be covered  Introduction to C Introduction to C  Characterstics of C Characterstics of C  Characterset Characterset  Keywords Keywords 
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
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.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
INTRODUCTION TO C LANGUAGE
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Introduction to ‘c’ language
Variables, Identifiers, Assignments, Input/Output
Basics (Variables, Assignments, I/O)
Data types Data types Basic types
BASIC ELEMENTS OF A COMPUTER PROGRAM
Wel come.
Basics (Variables, Assignments, I/O)
CSE101-Lec#3 Components of C Identifiers and Keywords Data types.
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.
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)
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Introduction to Java Programming
Variables in C Topics Naming Variables Declaring Variables
Basics of ‘C’.
An overview of Java, Data types and variables
Govt. Polytechnic,Dhangar
Variables, Identifiers, Assignments, Input/Output
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Variables in C Declaring , Naming, and Using Variables.
elementary programming
C programming Language
2. Second Step for Learning C++ Programming • Data Type • Char • Float
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Programming Language C Language.
Chap 2. Identifiers, Keywords, and Types
Lexical Elements & Operators
Variables in C Topics Naming Variables Declaring Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

C++ Basics

C++ BASICS C++ CHARACTER SET Letters A - Z, a – z Digits 0 -9 Special Symbols Space + - * / ^ \ ( ) [ ] { } = ≠ < > . ‘ “ $ , ; : % ! & ? _ # <= >= @ White Spaces Blank space, Horizontal tab (→) carriage return (← ), Newline, Form feed Other characters C++ can process any of the 256 ASCII characters as data or as literals

Tokens The smallest individual unit in a program Key words Identifiers Literals Punctuators Operators

KEYWORDS Words that convey special meaning to the language compiler break case catch char class const continue default delete do double else enum extern float for friend goto if inline integer long new 0perator private protected public register return short signed vsizeof static struct switch template this throw try typedef union unsigned virtual void

IDENTIFIERS An arbitrarily long sequence of letters and digits. The first character must be a letter: the underscore ( _) counts as a letter. Upper and lower-case letters are different. All characters are significant

VALID / INVALID IDENTIFIERS DATA-REC 29CLCT BREAK MY.FILE Myfile _CHK DATE9_7_77 MYFILE Z2TOZ9

LITERALS Data items that never change their value during a program run. integer– constants character–constant floating–constant string–constant

INTEGER CONSTANTS An integer constant must have at least one digit and must not contain any decimal point. It may contain either + or - sign . A number with no sign is assumed to be positive. Commas cannot appear in an integer constant

TYPES OF INTEGER CONSTANT Decimal Integer Constants (base10) Eg. 1234, 41, +97, - 12 Octal Integer Constants (base 8) Eg. 034, 071 etc.,( digits between 0 – 7 only) Hexadecimal Integer Constants (base 16) Eg. OCX etc.,

CHARACTER CONSTANT It must contain one character enclosed in single quotation marks Eg. ‘z’, ‘m’ etc.,

ESCAPE SEQUENCE IN C++ Escape Sequence Nongraphic Character \a Audible Bell (alert) \b Backspace \f Formfeed \n Newline or linefeed \r Carriage Return \t Horizontal tab \v Vertical Tab \\ Backslash \On Octal number (On represents the number in octal) \0 Null

FLOATING CONSTANT OR REAL CONSTANTS In fraction form Must have at least one digit before a decimal point and at least one digit after the decimal point. It may have either positive or negative sign preceding. By default with no sign it is positive. In Exponent form It has two parts : a mantissa and an exponent. The mantissa must be either an integer or a proper real constant. The exponent must be an integer. The mantissa is followed by a letter E

Valid / Nonvalid Real constants In fraction form In Exponent form Valid Invalid Valid Invalid 2.0 7 152E05 172.E5 17.5 7 1.52E07 1.7E -13.0 17250.26.2 0.1523E08 0.17E2.3 -0.00625 17,230.50 152.0E08 .25E-7

It is a sequence of characters surrounded by double quotes STRING LITERALS It is a sequence of characters surrounded by double quotes

Diagrammatic representation Literals Integer Constan t Character Constan t Floating Constan t String Literal Decimal Octal Hexa Decimal

PUNCTUATORS/ SEPERATORS [ ] ( ) { } , : ; * … = #

OPERATORS These are tokens that trigger some computation or action when applied to variables and other objects in an expression

Diagrammatic representation Token Keywords Identifiers Literals Punctuators Operators Integer Constant Character Constant Floating Constant String Literal Decimal Octal Hexa Decima l