C Programming Lecture-3 Keywords, Datatypes, Constants & Variables

Slides:



Advertisements
Similar presentations
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
Advertisements

Structure of a C program
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Data types and variables
CS150 Introduction to Computer Science 1
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
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.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Objectives You should be able to describe: Data Types
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.
Variables and Data Types
C Tokens Identifiers Keywords Constants Operators Special symbols.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
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.
CPS120: Introduction to Computer Science
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
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.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Chapter 5. Outline Some Exercises in C++ Names Variables Scope Lifetime.
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
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.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Chapter 2. Variable and Data type
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
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.
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.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
USER INTERACTION AND VARIABLES Tarik Booker CS 290 California State University, Los Angeles.
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.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Fundamentals 2.
Chapter # 2 Part 2 Programs And data
User Interaction and Variables
BASIC ELEMENTS OF A COMPUTER PROGRAM
Tokens in C Keywords Identifiers Constants
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.
ITEC113 Algorithms and Programming Techniques
Data Types, Identifiers, and Expressions
Revision Lecture
Constant Variable Expression
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.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Basics of ‘C’.
Unit-1 Introduction to Java
CS111 Computer Programming
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Lectures on Numerical Methods
Chapter # 2 Part 2 Programs And data
Chapter 2: Introduction to C++.
Lexical Elements & Operators
Variables and Constants
Programming Fundamental-1
Data Types and Arithmetic in C
Presentation transcript:

C Programming Lecture-3 Keywords, Datatypes, Constants & Variables $p!derLabWeb C Programming Lecture-3 Keywords, Datatypes, Constants & Variables

Keywords These are the reserved words which cannot be used as the identifiers name or constants or variable. They have the special meaning in the C language. These are some of the keywords in C:

Datatypes Datatype tells about the type of data it can store in the variable and how much space is given to the particular type. Different types of datatypes:- Integer type (char, int, short, long etc.) Floating-point type (float, double and long double)

Variables It is the name given to the storage area in the memory and can be manipulated according to the program. These are declared using datatypes which tells about the type of data to stored in it and how much storage is given to it.

Constants These are the fixed values which cannot be changed during the execution of program. These are also known as literals. These are some literals:- Integer literals 23 /* decimal */ 0157 /* octal */ 0x3e /* hexadecimal */ 36u /* unsigned int */ 75l /* long */ 56ul /* unsigned long */

Floating-point literals 1.569 /* Fractional form*/ 1569E-3 /* Exponantial form */ Character literals ‘d’ /* single character only used in between single quotes */ String literals “spiderlabweb” /* used in between double quotes */

Rules for writing a variable name It should not be a keyword. it can be composed of alphabets, numbers and underscore (_). It should not start with a number. It should be started with a alphabet or underscore (_) NOTE: lower and uppercase letters are treated differently.

Initialization and Declaration of variables Syntex for intialization of variales: type variable_name; eg. int a; /* initializing a of int type */ float b; ; /* initializing b of float type */ char c; ; /* initializing c of char type */

Syntex of declaration of variable: type variable_name = constants; Eg Syntex of declaration of variable: type variable_name = constants; Eg. int a = 10; /* assigning 10 to a of int type */ double b = 9.4675; /* assigning 9.4675 to b of double type */ char c =‘k’; /* assigning k to c of char type */

Thank you!