Presented By : Gaurav Juneja

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

Data Types and Variables in C language

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

C Language, Token, Keywords, Constant, variable

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

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

A Fast Review of C Essentials Part I

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

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

VARIABLES AND CONSTANTS

DEPARTMENT OF MATHS, MJ COLLEGE

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

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

Introduction to Computing Lecture 01: Introduction to C

Syntax and Variables

6.096 Introduction to C++ January (IAP) 2009

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

Differentiate Between Keywords and Identifiers

Creating a C++ Program

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

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

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

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

C: How to Program. Week /Mar/05

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

Tokens, Expressions and Control Structures

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

Fundamentals of Programming

BLM2031 Structured Programming. Zeyneb KURT

Chapter 2 - Introduction to C Programming

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

Chapter 1 & 2 Introduction to C Language

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

EECS 388 C Introduction. Gary J. Minden August 29, 2016

Basic Elements of C. Staff Incharge: S.Sasirekha

Programming in C and C++

Computers Programming Course 5. Iulian Năstac

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

ANSI C Programming Simple Programs

Programming and Data Structures

Programming in C and C++

CMPE-013/L. Introduction to C Programming

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

Structure of this course. C and C++ Past Exam Questions. Text books

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

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

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

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

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

Fundamental of Programming (C)

Motivation was to facilitate development of systems software, especially OS development.

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

CMSC 246 Systems Programming

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

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

(heavily based on last year s notes (Andrew Moore) with thanks to Alastair R. Beresford. 1. Types Variables Expressions & Statements 2/23

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

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

Motivation was to facilitate development of systems software, especially OS development.

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

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

Work relative to other classes

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

EL2310 Scientific Programming

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

edunepal_info

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

1.1 Introduction to C Language. Department of CSE

CS Programming In C

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

Programming. C++ Basics

CSc Introduction to Computing

Fundamental of C programming. - Ompal Singh

Introduction to C# Applications

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

Programming in C UVic SEng 265

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

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

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

INTRODUCTION 1 AND REVIEW

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

Binghamton University. CS-120 Summer Introduction to C. Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13

CS 61C: Great Ideas in Computer Architecture Introduction to C

Variables. Data Types.

C Overview Fall 2014 Jinkyu Jeong

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

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

In this session we will cover the following sub-topics: 1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.

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

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Programming. Data Structure

C Programming Language Training. This instruction relies on the C language described in C++: The Complete Reference Third Edition By Herbert Schildt

KARMAYOGI ENGINEERING COLLEGE, Shelve Pandharpur

Number Systems, Scalar Types, and Input and Output

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Computer programming & Data Structures Unit I Introduction to Computers

Transcription:

Presented By : Gaurav Juneja

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 of UNIX are written and run with the help of 'C'. Many of the important ideas of 'c' stem are from BCPL by Martin Richards. In 1972, Dennies Ritchie at Bell Laboratories wrote C Language which caused a revolution in computing world. From beginning C was intended to be useful for busy programmers to get things done easily because C is powerful,dominant and supple language.

Why Name 'C' was given to this language? Many of the ideas of C language were derived and taken from 'B' language. BCPL and CPL are previous versions of 'B' language. As many features came from B it was named as 'C'.

ABOUT C C programming language - Structured and disciplined approach to program design. o C is a structured programming language o C supports functions that enables easy maintainability of code, by breaking large file into smaller modules o Comments in C provides easy readability o C is a powerful language. o C programs built from Variable and type declarations Functions Statements Expressions

Structure Of C Programs Before going and reading the structure of C programs we need to have a basic knowledge of the following: 1. C's Character Set 2. C's Keywords 3.The General Structure of a 'C' Program 4. How To End A Statement 5. Free Format Language 6.Header Files & Library Functions

C's Character Set C does not use every character set and key found on modern computers. The only characters that C - Language uses for its programs are as follows: A-Z all alphabets a-z all alphabets 0-9 # % &! _ {} [] () $$$$ &&&& space., : ; ' $ " + - / * =

The keywords "Keywords" are words that have special meaning to the C compiler. Their meaning cannot be changed at any instance. Serve as basic building blocks for program statements. All keywords are written in only lowercase.

Basic Structure Of C Programs #include<stdio.h> #include<conio.h> void main() { } -- other statements Indicates Starting of Program Header Files Entry Point Of Program

Header files The files that are specified in the include section is called as Header File. These are precompiled files that has some functions defined in them. We can call those functions in our program by supplying parameters. Header file is given an extension.h. C Source file is given an extension.c.

Main function This is the Entry Point of a program. When a file is executed, the start point is the main function. From main function the flow goes as per the programmers choice. There may or may not be other functions written by user in a program. Main function is compulsory for any C program.

Running a C Program Type a program. Save it. Compile the program This will generate an.exe file (executable) Run the program (Actually the exe created out of compilation will run and not the.c file) In different compiler we have different option for compiling and running.

C language TOKENS The smallest individual units in a C program are known as tokens. In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements. C has 6 different types of tokens viz. 1. Keywords [e.g. float, int, while] 2. Identifiers [e.g. main, amount] 3. Constants [e.g. -25.6, 100] 4. Strings [e.g. SMIT, year ] 5. Special Symbols [e.g. {, }, [, ] ] 6. Operators [e.g. +, -, *] C - programs are written using these tokens and the general syntax. Strin gs

Keywords in Ansi C auto break case char const continue default do double else enum etern float for goto if register return short signed sizeof static struct int switch typedef union unsigned void volatile while long

The Identifiers They are programmer-chosen names to represent parts of the program: variables, functions, etc. Cannot use C keywords as identifiers Must begin with alpha character or _, followed by alpha, numeric, or _ Upper- and lower-case characters are important (casesensitive) Must consist of only letters, digits or underscore ( _ ). Only first 31 characters are significant. Must NOT contain spaces ( ).

Constants Constants in C are the fixed values that do not change during the execution of a program. CONSTANTS Numeric constants Character constants Integer Constants Real Constants Single Character Constants String Constants

Integer Constants Refers to sequence of digits such as decimal integer, octal integer and hexadecimal integer. Some of the examples are 112, 0551, 56579u, 0X2 etc. Real Constants Constants Examples The floating point constants such as 0.0083, -0.78, +67.89 etc. Single Character Constants A single char const contains a single character enclosed within pair of single quotes [ ]. For example, 8, a, i etc. String Constants A string constant is a sequence of characters enclosed in double quotes [ ]; For example, 0211, Stack Overflow etc.

DECLARATIONS Constants and variables must be declared before they can be used. A constant declaration specifies the type, the name and the value of the constant. any attempt to alter the value of a variable defined as constant results in an error message by the compiler A variable declaration specifies the type, the name and possibly the initial value of the variable. When you declare a constant or a variable, the compiler: Reserves a memory location in which to store the value of the constant or variable. Associates the name of the constant or variable with the memory location.

What Are Variables in C? A Variable is a data name that is used to store any data value. Variables are used to store values that can be changed during the program execution. Variables in C have the same meaning as variables in algebra. That is, they represent some unknown, or variable, value. x = a + b z + 2 = 3(y - 5) Remember that variables in algebra are represented by a single alphabetic character.

Naming Variables Variables in C may be given representations containing multiple characters. But there are rules for these representations. Variable names in C : May only consist of letters, digits, and underscores May be as long as you like, but only the first 31 characters are significant May not begin with a number May not be a C reserved word (keyword) Should start with a letter or an underscore(_) Can contain letters, numbers or underscore. No other special characters are allowed including space.

Case Sensitivity C is a case sensitive language. It matters whether an identifier, such as a variable name, is uppercase or lowercase. Example: area Area AREA ArEa are all seen as different variables by the compiler.

Declaring Variables Before using a variable, you must give the compiler some information about the variable; i.e., you must declare it. The declaration statement includes the data type of the variable. Examples of variable declarations: int length ; float area ; Variables are not automatically initialized. For example, after declaration int sum; the value of the variable sum can be anything (garbage). Thus, it is good practice to initialize variables when they are declared. Once a value has been placed in a variable it stays there until the program alters it.

Data types in ansi c There are three classes of data types here:: Primitive data types int, float, double, char Aggregate OR derived data types Arrays come under this category Arrays can contain collection of int or float or char or double data User defined data types Structures and enum fall under this category.

Data Types- different attributes Type Size Representation Minimum range Maximum range char, signed char 8 bits ASCII -128 127 unsigned char bool 8 bits ASCII 0 255 short, signed short 16 bits 2's complement -32768 32767 unsigned short 16 bits Binary 0 65535 int, signed int 16 bits 2's complement -32768 32767 unsigned int 16 bits Binary 0 65535 long, signed long 32 bits 2's complement -2,147,483,648 2,147,483,647 unsigned long 32 bits Binary 0 4,294,967,295 float 32 bits IEEE 32-bit 1.175495e-38 3.4028235e+38 double 32 bits IEEE 32-bit 1.175495e-38 3.4028235e+38 long double 32 bits IEEE 32-bit 1.175495e-38 3.4028235e+38

Example of C Program /* HELLO.C -- Hello, world */ #include <stdio.h> Void main() { printf("hello, world\n"); } Getch();