C Language, Token, Keywords, Constant, variable

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

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

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

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

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

6.096 Introduction to C++ January (IAP) 2009

Presented By : Gaurav Juneja

Intro to Computer Programming (ICP) Rab Nawaz Jadoon

Data Types and Variables in C language

Basic Elements of C. Staff Incharge: S.Sasirekha

VARIABLES AND CONSTANTS

DEPARTMENT OF MATHS, MJ COLLEGE

Work relative to other classes

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

C: How to Program. Week /Mar/05

Chapter 1 & 2 Introduction to C Language

Chapter 2 - Introduction to C Programming

Syntax and Variables

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Programming and Data Structures

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

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Fundamentals of C Programming

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

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

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Differentiate Between Keywords and Identifiers

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

1.1 Introduction to C Language. Department of CSE

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

Computers Programming Course 5. Iulian Năstac

Creating a C++ Program

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

CS102: Variables and Expressions

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

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

Fundamental of Programming (C)

Chapter 2: Overview of C. Problem Solving & Program Design in C

ANSI C Programming Simple Programs

Fundamentals of Programming

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14

Introduction to the C Programming Language

A Fast Review of C Essentials Part I

INTRODUCTION 1 AND REVIEW

Programming. C++ Basics

!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./

>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.

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

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

Chapter 1 Introduction to Computers and C++ Programming

CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso

COP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA

Preview from Notesale.co.uk Page 6 of 52

BLM2031 Structured Programming. Zeyneb KURT

Introduction to Computing Lecture 01: Introduction to C

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012

Programming in C. What is C?... What is C?

Programming in C UVic SEng 265

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Basic Types, Variables, Literals, Constants

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

Programming in C. What is C?... What is C?

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

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

Procedures, Parameters, Values and Variables. Steven R. Bagley

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

Informática Ingeniería en Electrónica y Automática Industrial

edunepal_info

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Introduction to C# Applications

Computer programming & Data Structures Unit I Introduction to Computers

Tokens, Expressions and Control Structures

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

from Appendix B: Some C Essentials

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

Chapter 2, Part I Introduction to C Programming

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

Lab # 02. Basic Elements of C++ _ Part1

C Programming Multiple. Choice

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

Typescript on LLVM Language Reference Manual

Chapter 2: Basic Elements of C++

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

PROGRAMMAZIONE I A.A. 2018/2019

ET156 Introduction to C Programming

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

C - Basic Introduction

C Programming Review CSC 4320/6320

CSCI 171 Chapter Outlines

Transcription:

C Language, Token, Keywords, Constant, variable

A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C Language is successor of earlier language B.

C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's Bell Laboratories in the 1972s in USA. It is also called as 'Procedure oriented programming language. C is not specially designed for specific applications areas like COBOL (Common Business-Oriented Language) or FORTRAN (Formula Translation). It is well suited for business and scientific applications.

System software Compilers, Editors, embedded systems Data compression, graphics and computational geometry, utility programs Databases, operating systems, device drivers, system level routines there are zillions of lines of C legacy code Also used in application programs

Four stages Editing: Writing the source code by using some IDE or editor Preprocessing or libraries: Already available routines compiling: translates or converts source to object code for a specific platform source code -> object code linking: resolves external references and produces the executable module Portable programs will run on any machine but.. Note! Program correctness and robustness are most important than program efficiency

Include files Global variable and function declaration Main functions Function subprogram

The preprocessor takes your source code and following certain directives that you give it tweaks it in various ways before compilation. A directive is given as a line of source code starting with the # symbol The preprocessor works in a very crude, wordprocessor way, simply cutting and pasting it doesn t really know anything about C! Your source code Enhanced and obfuscated source code Object code Preprocesso r Compiler

/* A first C Program*/ #include <stdio.h> void main() { printf("hello World \n"); }

Line 1: #include <stdio.h> As part of compilation, the C compiler runs a program called the C preprocessor. The preprocessor is able to add and remove code from your source file. In this case, the directive #include tells the preprocessor to include code from the file stdio.h. This file contains declarations for functions that the program needs to use. A declaration for the printf function is in this file.

Line 2: void main() This statement declares the main function. A C program can contain many functions but must always have one main function. A function is a self-contained module of code that can accomplish some task. Functions are examined later. The "void" specifies the return type of main. In this case, nothing is returned to the operating system.

Line 3: { This opening bracket denotes the start of the program.

Line 4: printf("hello World From About\n"); Printf is a function from a standard C library that is used to print strings to the standard output, normally your screen. The compiler links code from these standard libraries to the code you have written to produce the final executable. The "\n" is a special format modifier that tells the printf to put a line feed at the end of the line. If there were another printf in this program, its string would print on the next line.

Line 5: } This closing bracket denotes the end of the program.

\n \t \a \\ \ new line tab alert backslash double quote

Comment should be enclosed between /* */ It is used to increase the readability of the program. Any number of comments can be given at any place in the program. Comment cannot be nested It can be split over more than one line

Communicating with a computer involves speaking the language the computer understands. Steps in learning English language Alphabets Words Sentences Paragraph Steps in learning C Alphabets Digits Special-symbols Constants Variables Keywords Instruction Program

Communicating with a computer involves speaking the language the computer understands. Steps in learning English language Alphabets Words Sentences Paragraph Steps in learning C Alphabets Digits Special-symbols Constants Variables Keywords Instruction Program

A character denotes any alphabet, digit or special symbol used to represent information. Alphabets A,B,.,Y, Z a,b,..,y, z Digits 0,1,2,3,4,5,6,7,8,9 Special Symbols ~! @ # % ^ & * ( ) _ - + = \ { } [ ] : ; < >,.? /

Identifiers are names given to various program elements, such as variables, functions and arrays A variable name is any combination of alphabets, digits or underscores The first character in the variable name must be an alphabet

It is a data name which is used to store data and may change during program execution. It is opposite to constant. Variable name is a name given to memory cells location of a computer where data is stored.

First character should be letter or alphabet. Keywords are not allowed to use as a variable name. White space is not allowed. C is case sensitive i.e. UPPER and lower case are significant. Only underscore, special symbol is allowed between two characters. The length of indentifier may be upto 31 characters but only only the first 8 characters are significant by compiler.

A constant is a quantity that doesn t change. This quantity can be stored at a locations in the memory of the computer. Eg 3x + y = 20 3 & 20 are constants, which cannot change x & y can vary or change hence are called variables

C constants can be divided into two major categories Primary Constants Secondary Constants C Constants Primary Constants Integer Constant Real Constant Character Constant Secondary constants Array, Pointer Structure, Union Enum

An integer constant must have at least one digit It must not 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 an integer constant 1990, 194, -394

Real constants(rc) must have at least one digit It must have a decimal point It could be either positive or negative Default sign is positive No commas or blank are allowed within a RC 194.143, -416.41

A character constant is either a single alphabet, a single digit or a single special symbol enclosed within single inverted commas The maximum length of a character constant can be 1 character Eg a, 1, 5, = (Valid) asd, 12 (Invalid)

A String Constant consists of any number consecutive characters enclosed in double quotation marks Escape sequence can be embedded within the string.

Keywords are the words whose meaning has already been explained to the C compiler They cannot be used as variable names. There are only 32 keywords available in c auto double if static do break else int struct goto case enum long switch signed char extern near typedef while const float register union default continue far return unsigned for short void

C Supports several different types of data, each of which may be represented differently within the computers memory. Basic data types are listed below: Data Type Description Typical Memory int integer quantity 2 bytes char single character 1 bytes float floating point number 4 bytes double double-precision 8 bytes floating point number