Chapter 2: C Fundamentals Dr. Ameer Ali. Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions.

Slides:



Advertisements
Similar presentations
Fundamentals of Computer and programming in C
Advertisements

Data Types and Expressions
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Data types and variables
CS150 Introduction to Computer Science 1
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
Basic Elements of C++ Chapter 2.
Chapter 2 Data Types, Declarations, and Displays.
Objectives You should be able to describe: Data Types
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
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.
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.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
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.
Chapter 2: Using Data.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Windows Programming, C.-S. Shieh, KUAS EC, Chapter 3 Operators and Expressions.
CISC105 – General Computer Science Class 9 – 07/03/2006.
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.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Lesson 3 – Primitive Data Types Objective: Students will investigate the definition and usage of objects and primitive data types in Java in order to practice.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
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 TYPE AND DISPLAY Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
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.
Ch Chapter 4 Basic Data Types and Variables 4.1 Basic Data Types In C TABLE 4.1 Introduction to Basic Data Types in C Type SizeDescription char 1.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Topics to be covered  Introduction to C Introduction to C  Characterstics of C Characterstics of C  Characterset Characterset  Keywords Keywords 
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
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.
Variables Symbol representing a place to store information
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
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.
Characters and Strings
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Lecture 4 Monday Sept 9, Variables and Data Types ►A►A►A►A variable is simply a name given by the programmer that is used to refer to computer storage.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Constants, Data Types and Variables
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Wel come.
ITEC113 Algorithms and Programming Techniques
Java Programming: From Problem Analysis to Program Design, 4e
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 In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
C++ Basics.
Basics of ‘C’.
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Chapter 2 Primitive Data Types and Operations
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Programming Fundamental-1
Presentation transcript:

Chapter 2: C Fundamentals Dr. Ameer Ali

Overview C Character set Identifiers and Keywords Data Types Constants Variables and Arrays Declarations Expressions Statements Symbolic constants

C Characters A-Z, a-z, 0-9 +, -, &, ^, $, etc.

Identifiers Variable: a name given to a value to access using program such as sum_1, x1, y1, etc. Identifiers are names that are given to various program elements such as variables, functions and arrays. Identifiers consists of letters and digits in any order except that the first character must be a letter. Both upper case and lower case letters are accepted, but not interchangeable. Such as: Sum and uSm are two different.

Identifiers _ can be used. Arbitrarily long, but some C implementation can use only 8 characters such as file name.

Keywords Some reserved words that have standard and predefined meaning in C is known as keywords. Can only use for their intended purpose, not for other use. The standard keywords are: autobreakcasecharconstdodoubleelse enumforfloatgotoifintlongshort signedsizeofstaticstructswitchunionvoidwhile

Data Types Data Types DescriptionMemory (Byte) int long int Integer2 or 1 4 charSingle character1 floatFloating point4 doubleDouble precision floating point8

Data Types Int: short, long, signed, unsigned integer Ordinary integer int can carry only -32,768 to , while unsigned int can 0 to Char: One character 0 to 255 signed char can -128 to +127 Double, float can carry large values

Constants Four types of basic constants: Integers constant Floating point constant Character constants String constants Integer and floating-point constants are known as numeric constant and can be applied following rules Comma’s and blank spaces can not be included

Constants Constants can be preceded by – operator Value can not exceed minimum and maximum values

Integer Constants Is an integer valued numbers Consist of sequence of digits Can be written in three different format: Decimal Octal Hexa decimal Example: D-19278, O-12356, H-987ABC

Floating Point Constants E-17=5.036* E5=3.45*10 5

Character Constants ASCII: American Standard Code for Information Interchange

Character Constants

EBCDIC: extended binary coded decimal interchange code

Escape Sequences \ and ‘ can be expressed as escape sequence Line feed (LF): \n Others \t horizontal tab\v vertical tab \aalert\0 null \bbackspace

String Constants “abcdefgh”

Variables and Arrays Variables: used to represent some specific type of information within designated portion of the program A, b, c, abh, xyz. A=3; b=5; Array: is an identifier that refers to a collection of data items that all have the same name.

Array Index Value

Declarations Type Name; Int a; Float b; Char c; Double d; Type Name [Size] Int A[100]

Expression

Statements