SlideShare a Scribd company logo
Programming in C
A little history:
 1970’s
 Unix
 C, from BCPL (Thompson and Ritchie)
 C programming Language
 Widely used like the others: Fortran, Pascal
 Main form of language for system programming
 Available on any machine with C compiler and
library
Some Characteristics:
 Scope:
 Intended:

HPC, OS, general programming

Typically, long developing cycle

very platform dependent
 Not intended: web, scripting, data processing
 Features:
 Close interaction with system

Standard library (user-level only),

no other fancy stuff: networking, memory, graphics
 Extensive use of pointers
 Procedure (OOB) programming, strictly pass by value
Sample 1:
/* Hello World! */
#include <stdio.h>
int main()
{
printf(“Hello World!n”);
return 0;
}
Walk through:
 C program: hello.c
 emacs, vi, vim, pico, joe …
 But text editors only. No word processor
 Preprocessing: hello.s, assembly code
 cc -S hello.c
 Compilation: hello.o, a binary file
 cc -c hello.s
 Linking: a.out or hello, an executable file
 cc hello.o
 cc -o hello hello.o
 Loading (dynamical linking) and execution: ./hello
 ./a.out
 ./hello
Programming (Editing)
 C program: hello.c
 emacs, vi, vim, pico, joe …
 But text editors only. No word processor
Compile:
 Preprocessing: hello.s, assembly code
 cc -S hello.c
 Can you take a look at hello.s and compare to hello.c?
 Compilation: hello.o, a binary file
 cc -c hello.s
 Do you know how to take a look at hello.o?
 Linking: a.out or hello, an executable file
 cc hello.o
 cc -o hello hello.o
 Want to look at the executable, hello?
Run:
 Loading (dynamical linking) and execute: ./hello
 ./a.out
 ./hello
 What you do with java programs?
 What computer does to run your program?
Sample 1 Dissection:
 What it has?
 A function definition: main
 A line of comment
 A line of preprocessor directive
 An output statement
 A return clause
 What it does?
 Ask the computer to say hello to the world.
 What it does not do?
 It seems not computing!!
 No real work

not taking input

does not change any value
Sample 2:
#include <stdio.h>
#define MAGIC 10
int main(void)
{
int i, fact, quotient;
while (i++ < 3) {
printf(”Guess a factor of MAGIC larger than 1: ");
scanf("%d”, &fact);
quotient = MAGIC % fact;
if (0 == quotient)
printf(”You got it!n”);
else
printf(”Sorry, You missed it!n”);
}
return 0;
}
Sample 2 Dissection:
 What more it has?
 Macro definition
 Variable declaration
 Operations represented by operators
 Conditional computation
 Input Processing
 Loops: three chances
Syntax Dissection:
 What is syntax?
 m-w.com:

the way in which linguistic elements (as words) are put together
to form constituents (as phrases or clauses)
 How to put your C elements together into a program?
 Variable declaration,
 Identifier: case, keywords, style
 datatype specification

char, short, int, long, float, double
 Operators:
 +, -, *, /, %, ++, --; >, <, ==, ; &, |, …
 Priority and Precedence
 Associativity
More Syntax Dissection:
 Preprocessor directive
 macro
 header file inclusion
 Loop constructs
 for, while, do-while, break, continue, label--go;
 Conditional statements
 If, else, else if, switch, break
 Function definition
 return type, parameter definition, parameter passing
 Standard library and function calls
 Take home practice:
 Walk through the following steps with sample 2

preprocessing, compilation, linking, loading/execute

Modify and repeat once more if you can

More Related Content

What's hot

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

What's hot (20)

Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: Introduction
 
C++ language
C++ languageC++ language
C++ language
 
Vocabulary Types in C++17
Vocabulary Types in C++17Vocabulary Types in C++17
Vocabulary Types in C++17
 
To GO or not to GO
To GO or not to GOTo GO or not to GO
To GO or not to GO
 
C++17 std::filesystem - Overview
C++17 std::filesystem - OverviewC++17 std::filesystem - Overview
C++17 std::filesystem - Overview
 
A Tour of Go - Workshop
A Tour of Go - WorkshopA Tour of Go - Workshop
A Tour of Go - Workshop
 
The GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation WorldThe GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation World
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
 
Python vs c++ ppt
Python vs c++ pptPython vs c++ ppt
Python vs c++ ppt
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming language
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
Core Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th MayCore Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th May
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go language
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
C++ vs python the best ever comparison
C++ vs python the best ever comparison C++ vs python the best ever comparison
C++ vs python the best ever comparison
 
C# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageC# and the Evolution of a Programming Language
C# and the Evolution of a Programming Language
 

Viewers also liked

Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
_jenica
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
Suneel Dogra
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
vinay arora
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
Jeya Lakshmi
 

Viewers also liked (20)

C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
C
CC
C
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
Break and continue
Break and continueBreak and continue
Break and continue
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
 
Selection statements
Selection statementsSelection statements
Selection statements
 
Break and continue statement in C
Break and continue statement in CBreak and continue statement in C
Break and continue statement in C
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Ch3 selection
Ch3 selectionCh3 selection
Ch3 selection
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
Loops
LoopsLoops
Loops
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Loops
LoopsLoops
Loops
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 

Similar to C Lecture

Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
Amos Wenger
 

Similar to C Lecture (20)

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
Introduction
IntroductionIntroduction
Introduction
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 

More from Sudharsan S (20)

Xml1111
Xml1111Xml1111
Xml1111
 
Xml11
Xml11Xml11
Xml11
 
Xml plymouth
Xml plymouthXml plymouth
Xml plymouth
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
Xml
XmlXml
Xml
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Unix
UnixUnix
Unix
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Unix
UnixUnix
Unix
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
C Introduction
C IntroductionC Introduction
C Introduction
 
College1
College1College1
College1
 
C Programming
C ProgrammingC Programming
C Programming
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Preface
PrefacePreface
Preface
 
Toc Sg
Toc SgToc Sg
Toc Sg
 
Les08
Les08Les08
Les08
 
Les06
Les06Les06
Les06
 

Recently uploaded

Recently uploaded (20)

2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
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
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
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
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 

C Lecture

  • 2. A little history:  1970’s  Unix  C, from BCPL (Thompson and Ritchie)  C programming Language  Widely used like the others: Fortran, Pascal  Main form of language for system programming  Available on any machine with C compiler and library
  • 3. Some Characteristics:  Scope:  Intended:  HPC, OS, general programming  Typically, long developing cycle  very platform dependent  Not intended: web, scripting, data processing  Features:  Close interaction with system  Standard library (user-level only),  no other fancy stuff: networking, memory, graphics  Extensive use of pointers  Procedure (OOB) programming, strictly pass by value
  • 4. Sample 1: /* Hello World! */ #include <stdio.h> int main() { printf(“Hello World!n”); return 0; }
  • 5. Walk through:  C program: hello.c  emacs, vi, vim, pico, joe …  But text editors only. No word processor  Preprocessing: hello.s, assembly code  cc -S hello.c  Compilation: hello.o, a binary file  cc -c hello.s  Linking: a.out or hello, an executable file  cc hello.o  cc -o hello hello.o  Loading (dynamical linking) and execution: ./hello  ./a.out  ./hello
  • 6. Programming (Editing)  C program: hello.c  emacs, vi, vim, pico, joe …  But text editors only. No word processor
  • 7. Compile:  Preprocessing: hello.s, assembly code  cc -S hello.c  Can you take a look at hello.s and compare to hello.c?  Compilation: hello.o, a binary file  cc -c hello.s  Do you know how to take a look at hello.o?  Linking: a.out or hello, an executable file  cc hello.o  cc -o hello hello.o  Want to look at the executable, hello?
  • 8. Run:  Loading (dynamical linking) and execute: ./hello  ./a.out  ./hello  What you do with java programs?  What computer does to run your program?
  • 9. Sample 1 Dissection:  What it has?  A function definition: main  A line of comment  A line of preprocessor directive  An output statement  A return clause  What it does?  Ask the computer to say hello to the world.  What it does not do?  It seems not computing!!  No real work  not taking input  does not change any value
  • 10. Sample 2: #include <stdio.h> #define MAGIC 10 int main(void) { int i, fact, quotient; while (i++ < 3) { printf(”Guess a factor of MAGIC larger than 1: "); scanf("%d”, &fact); quotient = MAGIC % fact; if (0 == quotient) printf(”You got it!n”); else printf(”Sorry, You missed it!n”); } return 0; }
  • 11. Sample 2 Dissection:  What more it has?  Macro definition  Variable declaration  Operations represented by operators  Conditional computation  Input Processing  Loops: three chances
  • 12. Syntax Dissection:  What is syntax?  m-w.com:  the way in which linguistic elements (as words) are put together to form constituents (as phrases or clauses)  How to put your C elements together into a program?  Variable declaration,  Identifier: case, keywords, style  datatype specification  char, short, int, long, float, double  Operators:  +, -, *, /, %, ++, --; >, <, ==, ; &, |, …  Priority and Precedence  Associativity
  • 13. More Syntax Dissection:  Preprocessor directive  macro  header file inclusion  Loop constructs  for, while, do-while, break, continue, label--go;  Conditional statements  If, else, else if, switch, break  Function definition  return type, parameter definition, parameter passing  Standard library and function calls  Take home practice:  Walk through the following steps with sample 2  preprocessing, compilation, linking, loading/execute  Modify and repeat once more if you can

Editor's Notes

  1. My bias: C is hard and it is fun it embodies the most engineering art of programming