Differentiate Between Keywords and Identifiers

Similar documents
VARIABLES AND CONSTANTS

Chapter 2. Lexical Elements & Operators

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

BITG 1233: Introduction to C++

UNIT- 3 Introduction to C++

Presented By : Gaurav Juneja

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

BCA-105 C Language What is C? History of C

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Java Notes. 10th ICSE. Saravanan Ganesh

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

DEPARTMENT OF MATHS, MJ COLLEGE

Lexical Considerations

CS242 COMPUTER PROGRAMMING

1 Lexical Considerations

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

C Language, Token, Keywords, Constant, variable

C++ Programming: From Problem Analysis to Program Design, Third Edition

Full file at C How to Program, 6/e Multiple Choice Test Bank

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

BASIC ELEMENTS OF A COMPUTER PROGRAM

Programming in C++ 5. Integral data types

Visual C# Instructor s Manual Table of Contents

Data Types and Variables in C language

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

Computers Programming Course 5. Iulian Năstac

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

CS102: Variables and Expressions

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

6.096 Introduction to C++ January (IAP) 2009

Lexical Considerations

Creating a C++ Program

Chapter 2: Introduction to C++

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Work relative to other classes

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

Programming and Data Structures

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

LECTURE 02 INTRODUCTION TO C++

Computer Programming : C++

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

Preview from Notesale.co.uk Page 6 of 52

REVIEW. The C++ Programming Language. CS 151 Review #2

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

4. Inputting data or messages to a function is called passing data to the function.

Programming for Engineers Introduction to C

Basic Elements of C. Staff Incharge: S.Sasirekha

Chapter 2 Basic Elements of C++

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

Objectives. In this chapter, you will:

Programming in C++ 4. The lexical basis of C++

Chapter 2: Using Data

A Fast Review of C Essentials Part I

Lecture 2 Tao Wang 1

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

Fundamentals of Programming

Programming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme]

Fundamental of C programming. - Ompal Singh

Fundamental of Programming (C)

The C++ Language. Arizona State University 1

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

C - Basic Introduction

Basics of Java Programming

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Week 2 Introduction to Computer and Algorithm (Part 2)

ANSI C Programming Simple Programs

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

CSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018

3. Java - Language Constructs I

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

Lecture 3. More About C

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

JAVA Programming Fundamentals

CSCE 110 PROGRAMMING FUNDAMENTALS

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS201 Some Important Definitions

CSC 1107: Structured Programming

These are reserved words of the C language. For example int, float, if, else, for, while etc.

Computer System and programming in C

CHAPTER-6 GETTING STARTED WITH C++

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CHAPTER 3 BASIC INSTRUCTION OF C++

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Fundamentals of C. Structure of a C Program

Chapter 2 THE STRUCTURE OF C LANGUAGE

C: How to Program. Week /Mar/05

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

Chapter 2 Working with Data Types and Operators

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Introduction to C. Winter 2019

Transcription:

History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os) OS is software which controls the various processes in a computer system. This language was later improved by Ken Thompson and he gave it a new name B. The basic ideas about some topics such as arrays, etc., which were later inherited by C were developed in BCPL and B. Differentiate Between Keywords and Identifiers Keywords are special words that have special meaning in the C language and are reserved by the language. An identifier is a string of alphanumeric characters that begins with an alphabetic character or an underscore character that are used to represent various programming elements such as variables, functions, arrays, structures, unions and so on. Actually, an identifier is a user-defined word. e.g identifiers: total sum average _x y_ mark_1 x1 What is the importance of header files The main role of header file is it is used to share information among various files. To put it brief, if we have several functions say 4 functions named as f1, f2, f3, f4 placed in file say sample c and if all the functions want to get accessed each other all must be placed in the same file sample c Anatomy of C Program We have some compiler preprocessor commands. This includes various #include files. Then comes the main function. Some name can also be given to the main function. Then, we have the variable declarations used in the main code. Then we have sub-functions.

Basic Data Types and Operators The type of a variable determines what kinds of values it may take on. An operator computes new values out of old ones. An expression consists of variables, constants, and operators combined to perform some useful computation. There are only a few basic data types in C char a character int an integer, in the range -32,767 to 32,767 long int a larger integer (up to +-2,147,483,647) float a floating-point number double a floating-point number, with more precision and perhaps greater range than float Constants Constants are also like normal variables. But, only difference is, their values can not be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals. Constants may be belonging to any of the data type We can define constants in a C program in the following ways. By const keyword By #define preprocessor directive

TYPES OF C CONSTANT: 1. Integer constants 2. Real or Floating point constants 3. Octal & Hexadecimal constants 4. Character constants 5. String constants 6. Backslash character constants RULES FOR CONSTRUCTING C CONSTANT: 1. INTEGER CONSTANTS IN C: An integer constant must have at least one digit. It must not have a decimal point. It can either be positive or negative. No commas or blanks are allowed within an integer constant. If no sign precedes an integer constant, it is assumed to be positive. The allowable range for integer constants is -32768 to 32767. 2. REAL CONSTANTS IN C: A real constant must have at least one digit It must have a decimal point It could be either positive or negative If no sign precedes an integer constant, it is assumed to be positive. No commas or blanks are allowed within a real constant.

3. CHARACTER AND STRING CONSTANTS IN C: A character constant is a single alphabet, a single digit or a single special symbol enclosed within single quotes. The maximum length of a character constant is 1 character. String constants are enclosed within double quotes 4. BACKSLASH CHARACTER CONSTANTS IN C: There are some characters which have special meaning in C language. They should be preceded by backslash symbol to make use of special function of them. Given below is the list of special characters and their purpose.

#include <stdio.h> void main() { const int height = 100; /*int constant*/ const float number = 3.14; /*Real constant*/ const char letter = 'A'; /*char constant*/ const char letter_sequence[10] = "ABC"; /*string constant*/ const char backslash_char = '\?'; /*special char cnst*/ printf("value of height :%d \n", height ); printf("value of number : %f \n", number ); printf("value of letter : %c \n", letter ); printf("value of letter_sequence : %s \n", letter_sequence); printf("value of backslash_char : %c \n", backslash_char); } Variable A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is case-sensitive. e.g. int i, j, k; char c, ch; float f, salary; double d;

#include <stdio.h> // Variable declaration: extern int a, b; extern int c; extern float f; int main () { /* variable definition: */ int a, b; int c; float f; /* actual initialization */ a = 10; b = 20; c = a + b; printf("value of c : %d \n", c); f = 70.0/3.0; printf("value of f : %f \n", f); } return 0; When the above code is compiled and executed, it produces the following result value of c : 30 value of f : 23.333334

Arithmetic Operators The basic operators for performing arithmetic are the same in many computer languages: Assignment Operators The assignment operator = assigns a value to a variable. For example, x = 1 a = b sets x to 1, and sets a to whatever b's value is.

Relational Operators Logical Operators

Increment and Decrement Operators Increment and decrement operators are unary operators that add or subtract one from their operand, respectively. They are commonly implemented in imperative programming languages-like languages feature two versions (pre- and post-) of each operator with slightly different semantics. Pre Increment, Decrement & Post Increment, Decrement Operators int x; int y; // Increment operators x = 1; y = ++x; // x is now 2, y is also 2 y = x++; // x is now 3, y is 2 // Decrement operators x = 3; y = x--; // x is now 2, y is 3 y = --x; // x is now 1, y is also 1