SlideShare a Scribd company logo
Introduction to
Farzana Shah
(BS-IT, MBA-HRM)
Lecturer : (Computer Science)
Contents
LEC# 03
Introduction
History
Features
Program compilation process
Program structure
 Examples
 Escape Sequance
 Examples
 Comments
 Examples
 C Language Errors
2
What is c language:-
C is mother language of all programming
language.
It is system programming language.
It is procedure-oriented programming
language.
It is also called mid level programming
language.
A brief history of C
 C evolved from a language called B, written by Ken Thompson at Bell Labs in 1970.
Ken used B to write one of the first implementations of UNIX. B in turn was a
descendant of the language BCPL (developed at Cambridge (UK) in 1967), with most
of its instructions removed.
 So many instructions were removed in going from BCPL to B, that Dennis Ritchie of
Bell Labs put some back in (in 1972), and called the language C.
 The famous book The C Programming Language was written by Kernighan and
Ritchie in 1978, and was the definitive reference book on C for almost a decade.
 The original C was still too limiting, and not standardized, and so in 1983 an ANSI
committee was established to formalise the language definition.
 It has taken until now (ten years later) for the ANSI ( American National Standard
Institute) standard to become well accepted and almost universally supported by
compilers
Language year Developed By
ALGOL 1960 InternationalGroup
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan &Dennis Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISOC 1990 ISO Committee
C99 1999 Standardization
Committee
Summary of C language history
Features ofC
The main features of C is; It is Structure oriented
programming languageand it isaverysimpleandeasy
languageztoreadandwrite,
Credit: Tutorial4us.com
Someimportant featuresof C are
1. Structure Oriented
2. PlatformDependent
3. CompilerBased
4.Simpleand easyto learn
5. Hug functionlibrary
6. Usesof pointerconcept
7.Syntaxbased
8, PowerFull
9. Middlelevel programming
10. CaseSensitive
IDE: The Integrated Development Environment
 Turbo c features as integrated Development
environment, or IDE,. It is also referred to as the
programmer’s platform.) in IDE you can able to
write/save/open your programs or code, compile
using short cut keys, and also perform code
debugging very easily.
 Common Short cut Keys Description
 F2 press to Save current work
 F3 press to open an existing file
 ALT-F3 press to close current
 ALT-F9 press to compile only
 ALT-F5 press to view the desired output of the
program.
 CTRL-F9 press to compile+run
 ALT-X or ALT-F-X press to exit from TC IDE
IDE: The Integrated Development Environment
C Programs STRUCTURE (General)
 <Preprocessor Directives (some time necessary)>
 <Macros Definition (optional)>
 <function declaration>
 < Global Variable (on your demand)>
 main () (Necessary)
 { statements }
 < function definition>
 { }
Remember Some common rules for writing C
program
 Use all commands or statements in lower or small case.
 After completion of a statement excluding main() or loops must
insert ; (semicolon) as a statement terminator.
 Don’t use/declare identifier or variable name same as statement
name suppose int
 include; this is a wrong statement because include has a special
meaning in the language.
Learning C:
z
Compiling & Executing C Program:
Compiling & Executing C Programs
 C compiler: This program translates the C language source code
into the machine assembly language.
 Assembler: The assembler accepts the C – compiler output and
creates object code. If the program does not contain any external
function calls, this code is directly executable.
 Linker: If a source file references library functions, which is
defined in other source files, the linker combines these functions
with the main() function to create an executable program file.
C Program: Steps
 Step 1: The program that is to be compiled is first typed into a
file on the computer system. There are various conventions that
are used for naming files, typically be any name provided the last
two characters are “.c” or file with extension .c. So, the file name
prog1.c might be a valid filename for a C program. The program
that is entered into the file
 is known as the source program because it represents the
original form of the program expressed in the C language.
C Program: Steps
 Step 2: After the source program has been entered
into a file, then proceed to have it compiled.
 Typical errors reported during this phase of
compilation might be due to an expression that has
unbalanced parentheses (syntactic error), or due to
the use of a variable that is not “defined” (semantic
error).
C Program: Steps
 Step 3: When all the syntactic and semantic errors
have been removed from the program, the compiler
then proceeds to take each statement of the program
and translate it into a “lower” form that is equivalent
to assembly language program needed to perform
the identical task.
C Program: Steps
 Step 4: After the program has been translated the
next step in the compilation process is to translate
the assembly language statements into actual
machine instructions. The assembler takes each
assembly language statement and converts it into a
binary format known as object code, which is then
written into another file on the system. This file has
the same name as the source file under Unix, with
the last letter an “o” (for object) instead of a “c”.
C Program: Steps
 Step 5: After the program has been translated into
object code, it is ready to be linked. This process is
once again performed automatically whenever the cc
or gcc command is issued under Unix. The purpose
of the linking phase is to get the program into a final
form for execution on the computer.
C Program: Steps
 Step 6: The final linked file, which is in an
executable object code format, is stored in another
file on the system, ready to be run or executed..
Header Files or Preprocessor Directives
 C preprocessor: This program accepts C source files as input and
produces a file that is passed to the compiler.
 The preprocessor is responsible for removing comments and interpreting
special C language pre-processor directives, which can be easily
identified as they begin with the # symbol.
 # include: The preprocessor adds the information about the object code
used in the body of the main function. These files are called headerfiles.
 # define: this directive assigns a symbolic name to a constant.
 Symbolic names are used to make programs more readable and
maintainable.
Header Files or Preprocessor Directives
 Header Files or Preprocessor Directives contains references or links of
 library functions. That is built-in in the C language.
 Suppose if you want to use a function clrscr() ; in the main function so must be
declared on top # include <conio.h> other wise you could have an prototype error.
 Some header files are as follows
 Stdio.h
 Conio.h
 Dos.h
 String.h
 math.h
 And many more header files are available in C…
Main() function: void main(void)
 Every C programs consists of one or more functions. No
matter how many functions there are in a C program , main
is the one to which control is passed from the operating
system when the program is run ; it is the first function
executed.
 The word "void" preceding "main" specifies that the function
main() will not return a value.
 The second "void," in parenthesis , specifies that the
function takes no arguments.
printf() function
 printf() is built-in function we can display with
printf() any message, variable value on
screen/file/printer.
 In printf() we can use many escape
sequences and format specifies.
First Program of C Language:-
#include <stdio.h>
#include <conio.h>
void main(){
printf("Hello CLanguage");
getch();
}
Output of Program is:-
Hello CLanguage
Describe theC Program:-
#include <stdio.h> includes the standard input
output library functions. The printf() function is defined in
stdio.h .
#include <conio.h> includes the console input
output library functions. The getch() function is defined in
conio.h file.
void main() The main() function is the entry point of
every program in c language. The void keyword specifies
that it returns no value.
printf() The printf() function is used to print data on the
console.
getch() The getch() function asks for a single
character. Until you press any key, it blocks the screen.
Escape sequences
 Escape sequences are special notations through which we can display our data Variety of
ways:
 Some escape sequences and their functions are as follows:
Perform line feed (new line ) & Carriage return operation printf("AnB");
 Escape Sequence Description Example
 n
 t
 ’
 “
 r
 b
Prints a tab sequence on screen printf ("Atb");
Prints a single quote character on screen printf ("’a’");
Prints a double quote character on Screen printf (""a"");
Perform carriage return operation printf ("arb")
Remove one character from left printf ("abHi!" );
Escape Sequence
Program of CLanguage:-
#include <stdio.h>
#include <conio.h>
void main(void)
{
clrscr();
printf( " " C Language" n");
getch();
}
Output:
" C Language "
Output of Program is:-
Rules for Comment
 Comments : code which are not executable statement, of
necessary can be placed in between /* and */.
 Comment in the program should be enclosed within /* .. */ .Look example below
the first line is comment.
 For ex. /*This my first program*/
 #include<stdio.h>
 main()
 {
 Statement;
 Statement;
 }
Rules for Comment
 Though comments are not necessary, but it good practice to begin programwith
comment indicating purpose of program so that other person can get idea of
program.
 You can write any number comment at any place in program mentioning the
purpose of the statement.
 Use few Comment instead of too many.
 A comment cannot be nested. For ex., /* The/*first/*program*/*/*/.
 // use for single line comment and /* */ multiple line
 A comment can split over more than one line. Forex.
/*THE
First
Program*/
Escape Sequence, Comments use in CLanguage:-
Output of Program is:-
C Programming Error Types – Runtime,
Compile & Logical Errors
 While writing c programs, errors also known as bugs in the world
of programming may occur unwillingly which may prevent the
program to compile and run correctly as per the expectation of
the programmer.
 Basically there are three types of errors in c programming:
 Runtime Errors
 Compile Errors
 Logical Errors
C Runtime Errors
 C runtime errors are those errors that occur during the
execution of a c program and generally occur due to some
illegal operation performed in the program.
 Examples of some illegal operations that may produce
runtime errors are:
 Dividing a number by zero
 Trying to open a file which is not created
 Lack of free memory space
Compile Errors
 Compile errors are those errors that occur at the time of compilation
of the program. C compile errors may be further classified as:
 Syntax Errors
 When the rules of the c programming language are not followed,
the compiler will show syntax errors.
 For example, consider the statement:
int a,b:
 The above statement will produce syntax error as the statement is
terminated with : rather than ;
Compile Errors
 Semantic Errors
 Semantic errors are reported by the compiler when the
statements written in the c program are not meaningful to the
compiler.
 For example, consider the statement,
b+c=a;
 In the above statement we are trying to assign value of a in the
value obtained by summation of b and c which has no meaning
in c. The correct statement will be
a=b+c;
Logical Errors
 Logical errors are the errors in the output of the
program. The presence of logical errors leads to
undesired or incorrect output and are caused due to
error in the logic applied in the program to produce the
desired output.
 Also, logical errors could not be detected by the
compiler, and thus, programmers has to check the
entire coding of a c program line by line.
Thank you
Question &
Answer

More Related Content

What's hot

The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
Prof Ansari
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
Akshay Ithape
 
C basics
C   basicsC   basics
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
nTier Custom Solutions
 
Computer programming chapter ( 3 )
Computer programming chapter ( 3 ) Computer programming chapter ( 3 )
Computer programming chapter ( 3 )
Ibrahim Elewah
 
C Language
C LanguageC Language
C Language
Aakash Singh
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports Sunil Kumar R
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)
Abhishek Walia
 
Brief introduction to the c programming language
Brief introduction to the c programming languageBrief introduction to the c programming language
Brief introduction to the c programming languageKumar Gaurav
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Programming in c
Programming in cProgramming in c
Programming in c
indra Kishor
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)indrasir
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
Nuzhat Memon
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming
Hemantha Kulathilake
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chaptersIbrahim Elewah
 
C programming basics
C  programming basicsC  programming basics
C programming basics
argusacademy
 

What's hot (20)

The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C basics
C   basicsC   basics
C basics
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Computer programming chapter ( 3 )
Computer programming chapter ( 3 ) Computer programming chapter ( 3 )
Computer programming chapter ( 3 )
 
C Language
C LanguageC Language
C Language
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)
 
Brief introduction to the c programming language
Brief introduction to the c programming languageBrief introduction to the c programming language
Brief introduction to the c programming language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chapters
 
C programming basics
C  programming basicsC  programming basics
C programming basics
 

Similar to Introduction of c language

C language
C languageC language
C language
marar hina
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
CoolGamer16
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
BAKRANIYA KALPESH
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Anandhasilambarasan D
 
C
CC
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
Abdalla536859
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
Muhammed Thanveer M
 
Chapter 3(1)
Chapter 3(1)Chapter 3(1)
Chapter 3(1)
TejaswiB4
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
Rokonuzzaman Rony
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
vino108206
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
Subramanyambharathis
 
C_Intro.ppt
C_Intro.pptC_Intro.ppt
C_Intro.ppt
gitesh_nagar
 
C Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDYC Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDYRajeshkumar Reddy
 
C intro
C introC intro
C intro
Mohit Patodia
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
SeethaDinesh
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
Mitali Chugh
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
aaravSingh41
 

Similar to Introduction of c language (20)

C language
C languageC language
C language
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C
CC
C
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
Programming in c
Programming in cProgramming in c
Programming in c
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
Chapter 3(1)
Chapter 3(1)Chapter 3(1)
Chapter 3(1)
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
C_Intro.ppt
C_Intro.pptC_Intro.ppt
C_Intro.ppt
 
C Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDYC Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDY
 
C intro
C introC intro
C intro
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
 

More from farishah

INTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWAREINTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWARE
farishah
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
farishah
 
Computer applications to business
Computer applications to businessComputer applications to business
Computer applications to business
farishah
 
Types of software
Types of softwareTypes of software
Types of software
farishah
 
Algorithm
AlgorithmAlgorithm
Algorithm
farishah
 
Letter writing essentials
Letter writing essentialsLetter writing essentials
Letter writing essentials
farishah
 

More from farishah (6)

INTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWAREINTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWARE
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
 
Computer applications to business
Computer applications to businessComputer applications to business
Computer applications to business
 
Types of software
Types of softwareTypes of software
Types of software
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Letter writing essentials
Letter writing essentialsLetter writing essentials
Letter writing essentials
 

Recently uploaded

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 

Recently uploaded (20)

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 

Introduction of c language

  • 1. Introduction to Farzana Shah (BS-IT, MBA-HRM) Lecturer : (Computer Science)
  • 2. Contents LEC# 03 Introduction History Features Program compilation process Program structure  Examples  Escape Sequance  Examples  Comments  Examples  C Language Errors 2
  • 3. What is c language:- C is mother language of all programming language. It is system programming language. It is procedure-oriented programming language. It is also called mid level programming language.
  • 4. A brief history of C  C evolved from a language called B, written by Ken Thompson at Bell Labs in 1970. Ken used B to write one of the first implementations of UNIX. B in turn was a descendant of the language BCPL (developed at Cambridge (UK) in 1967), with most of its instructions removed.  So many instructions were removed in going from BCPL to B, that Dennis Ritchie of Bell Labs put some back in (in 1972), and called the language C.  The famous book The C Programming Language was written by Kernighan and Ritchie in 1978, and was the definitive reference book on C for almost a decade.  The original C was still too limiting, and not standardized, and so in 1983 an ANSI committee was established to formalise the language definition.  It has taken until now (ten years later) for the ANSI ( American National Standard Institute) standard to become well accepted and almost universally supported by compilers
  • 5. Language year Developed By ALGOL 1960 InternationalGroup BPCL 1967 Martin Richards B 1970 Ken Thompson Traditional C 1972 Dennis Ritchie K & R C 1978 Kernighan &Dennis Ritchie ANSI C 1989 ANSI Committee ANSI/ISOC 1990 ISO Committee C99 1999 Standardization Committee Summary of C language history
  • 6. Features ofC The main features of C is; It is Structure oriented programming languageand it isaverysimpleandeasy languageztoreadandwrite,
  • 8. Someimportant featuresof C are 1. Structure Oriented 2. PlatformDependent 3. CompilerBased 4.Simpleand easyto learn 5. Hug functionlibrary 6. Usesof pointerconcept 7.Syntaxbased 8, PowerFull 9. Middlelevel programming 10. CaseSensitive
  • 9. IDE: The Integrated Development Environment  Turbo c features as integrated Development environment, or IDE,. It is also referred to as the programmer’s platform.) in IDE you can able to write/save/open your programs or code, compile using short cut keys, and also perform code debugging very easily.
  • 10.
  • 11.  Common Short cut Keys Description  F2 press to Save current work  F3 press to open an existing file  ALT-F3 press to close current  ALT-F9 press to compile only  ALT-F5 press to view the desired output of the program.  CTRL-F9 press to compile+run  ALT-X or ALT-F-X press to exit from TC IDE IDE: The Integrated Development Environment
  • 12. C Programs STRUCTURE (General)  <Preprocessor Directives (some time necessary)>  <Macros Definition (optional)>  <function declaration>  < Global Variable (on your demand)>  main () (Necessary)  { statements }  < function definition>  { }
  • 13. Remember Some common rules for writing C program  Use all commands or statements in lower or small case.  After completion of a statement excluding main() or loops must insert ; (semicolon) as a statement terminator.  Don’t use/declare identifier or variable name same as statement name suppose int  include; this is a wrong statement because include has a special meaning in the language.
  • 16. Compiling & Executing C Programs  C compiler: This program translates the C language source code into the machine assembly language.  Assembler: The assembler accepts the C – compiler output and creates object code. If the program does not contain any external function calls, this code is directly executable.  Linker: If a source file references library functions, which is defined in other source files, the linker combines these functions with the main() function to create an executable program file.
  • 17. C Program: Steps  Step 1: The program that is to be compiled is first typed into a file on the computer system. There are various conventions that are used for naming files, typically be any name provided the last two characters are “.c” or file with extension .c. So, the file name prog1.c might be a valid filename for a C program. The program that is entered into the file  is known as the source program because it represents the original form of the program expressed in the C language.
  • 18. C Program: Steps  Step 2: After the source program has been entered into a file, then proceed to have it compiled.  Typical errors reported during this phase of compilation might be due to an expression that has unbalanced parentheses (syntactic error), or due to the use of a variable that is not “defined” (semantic error).
  • 19. C Program: Steps  Step 3: When all the syntactic and semantic errors have been removed from the program, the compiler then proceeds to take each statement of the program and translate it into a “lower” form that is equivalent to assembly language program needed to perform the identical task.
  • 20. C Program: Steps  Step 4: After the program has been translated the next step in the compilation process is to translate the assembly language statements into actual machine instructions. The assembler takes each assembly language statement and converts it into a binary format known as object code, which is then written into another file on the system. This file has the same name as the source file under Unix, with the last letter an “o” (for object) instead of a “c”.
  • 21. C Program: Steps  Step 5: After the program has been translated into object code, it is ready to be linked. This process is once again performed automatically whenever the cc or gcc command is issued under Unix. The purpose of the linking phase is to get the program into a final form for execution on the computer.
  • 22. C Program: Steps  Step 6: The final linked file, which is in an executable object code format, is stored in another file on the system, ready to be run or executed..
  • 23. Header Files or Preprocessor Directives  C preprocessor: This program accepts C source files as input and produces a file that is passed to the compiler.  The preprocessor is responsible for removing comments and interpreting special C language pre-processor directives, which can be easily identified as they begin with the # symbol.  # include: The preprocessor adds the information about the object code used in the body of the main function. These files are called headerfiles.  # define: this directive assigns a symbolic name to a constant.  Symbolic names are used to make programs more readable and maintainable.
  • 24. Header Files or Preprocessor Directives  Header Files or Preprocessor Directives contains references or links of  library functions. That is built-in in the C language.  Suppose if you want to use a function clrscr() ; in the main function so must be declared on top # include <conio.h> other wise you could have an prototype error.  Some header files are as follows  Stdio.h  Conio.h  Dos.h  String.h  math.h  And many more header files are available in C…
  • 25. Main() function: void main(void)  Every C programs consists of one or more functions. No matter how many functions there are in a C program , main is the one to which control is passed from the operating system when the program is run ; it is the first function executed.  The word "void" preceding "main" specifies that the function main() will not return a value.  The second "void," in parenthesis , specifies that the function takes no arguments.
  • 26. printf() function  printf() is built-in function we can display with printf() any message, variable value on screen/file/printer.  In printf() we can use many escape sequences and format specifies.
  • 27. First Program of C Language:- #include <stdio.h> #include <conio.h> void main(){ printf("Hello CLanguage"); getch(); }
  • 28. Output of Program is:- Hello CLanguage
  • 29. Describe theC Program:- #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h . #include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file. void main() The main() function is the entry point of every program in c language. The void keyword specifies that it returns no value. printf() The printf() function is used to print data on the console. getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.
  • 30. Escape sequences  Escape sequences are special notations through which we can display our data Variety of ways:  Some escape sequences and their functions are as follows: Perform line feed (new line ) & Carriage return operation printf("AnB");  Escape Sequence Description Example  n  t  ’  “  r  b Prints a tab sequence on screen printf ("Atb"); Prints a single quote character on screen printf ("’a’"); Prints a double quote character on Screen printf (""a""); Perform carriage return operation printf ("arb") Remove one character from left printf ("abHi!" );
  • 31. Escape Sequence Program of CLanguage:- #include <stdio.h> #include <conio.h> void main(void) { clrscr(); printf( " " C Language" n"); getch(); } Output: " C Language "
  • 33. Rules for Comment  Comments : code which are not executable statement, of necessary can be placed in between /* and */.  Comment in the program should be enclosed within /* .. */ .Look example below the first line is comment.  For ex. /*This my first program*/  #include<stdio.h>  main()  {  Statement;  Statement;  }
  • 34. Rules for Comment  Though comments are not necessary, but it good practice to begin programwith comment indicating purpose of program so that other person can get idea of program.  You can write any number comment at any place in program mentioning the purpose of the statement.  Use few Comment instead of too many.  A comment cannot be nested. For ex., /* The/*first/*program*/*/*/.  // use for single line comment and /* */ multiple line  A comment can split over more than one line. Forex. /*THE First Program*/
  • 35. Escape Sequence, Comments use in CLanguage:-
  • 37. C Programming Error Types – Runtime, Compile & Logical Errors  While writing c programs, errors also known as bugs in the world of programming may occur unwillingly which may prevent the program to compile and run correctly as per the expectation of the programmer.  Basically there are three types of errors in c programming:  Runtime Errors  Compile Errors  Logical Errors
  • 38. C Runtime Errors  C runtime errors are those errors that occur during the execution of a c program and generally occur due to some illegal operation performed in the program.  Examples of some illegal operations that may produce runtime errors are:  Dividing a number by zero  Trying to open a file which is not created  Lack of free memory space
  • 39. Compile Errors  Compile errors are those errors that occur at the time of compilation of the program. C compile errors may be further classified as:  Syntax Errors  When the rules of the c programming language are not followed, the compiler will show syntax errors.  For example, consider the statement: int a,b:  The above statement will produce syntax error as the statement is terminated with : rather than ;
  • 40. Compile Errors  Semantic Errors  Semantic errors are reported by the compiler when the statements written in the c program are not meaningful to the compiler.  For example, consider the statement, b+c=a;  In the above statement we are trying to assign value of a in the value obtained by summation of b and c which has no meaning in c. The correct statement will be a=b+c;
  • 41. Logical Errors  Logical errors are the errors in the output of the program. The presence of logical errors leads to undesired or incorrect output and are caused due to error in the logic applied in the program to produce the desired output.  Also, logical errors could not be detected by the compiler, and thus, programmers has to check the entire coding of a c program line by line.