SlideShare a Scribd company logo
1 of 49
Download to read offline
1
Programming Fundamentals
Outline
• Course introduction
• Programming languages concepts
• C Programming Basics
2
Course Introduction
Course Introduction
• Course CHs:
– 03 CHs (42 lectures) :
Attendance 05
Lab Evaluation Work 15
3
• Theoretical work
Maximum Marks 100
Attendance 10
Tests 05
Assignments 05
Mid Semester Examination 20
Final Semester Examination 60
– 1CHs (42 lectures) :
• Practical work
Semester Lab Examination 30
Course Introduction
4
• Recommended Text Book:
– Turbo C Programming for the PC
» Robert Lafore
• Reference Books:
– Let Us C, Lates Edition
» Yashavant P. Kanetkar
– A Book On C
» Al Kelley and Ira Pohl
• Online Literature/Tutorials etc.
Course Introduction
5
• Recommended Tool:
– DevC++
• Practical: SD Lab
– Class exercises and lab tasks
– Assisted by Mr. Shabir Ali Shah
• Teaching plan:
– 02 tests:
• Each after 20TH
and 35TH
lectures
– Assignments
Course Introduction
6
• At the end of each book chapter (Robert Lafore)
• Assignments are to be collected 1 week after 42nd
lecture
– Practical exercises:
• Almost in each practical
• Maintenance of practical
• C project
• C projects
– ATM
– Marks Certificate
Course Introduction
7
– Traffic Control System
– Simple Games
– …
• Lecture slides/announcements/results can
be found at course home page:
http://saleem.quest.edu.pk/
8
Important Instructions
• During the class:
– Keep silent
– Turn off mobile phones
– No attendance for late comers
9
Programming Languages Concept
• What is a programming language?
• Why do we need programming languages?
• What are the types of programming languages?
Programming Languages Concepts
10
• What is a programming language?
– A programming language is a set of rules that provides
a way of telling a computer how and what operations
to perform.
• What is a programming language?
– The description of a programming language is usually
split into the two components of syntax (form) and
semantics (meaning).
Programming Languages Concepts
11
– A program can execute only if it is both syntactically
and semantically correct.
• Why do we need programming languages?
– Facilitate users in performing tasks which are:
1. Faster,
2. Correct, and
3. Economically cheaper
3. What are the types of programming language?
Programming Languages Concepts
12
– Programming languages may be divided into three (03)
general types:
1. Machine languages
2. Assembly languages
3. High-level languages
• Machine languages
– Strings of 0’s and 1’s telling computers to perform
basic operations one at a time; e.g.:
01001110
00111001
Programming Languages Concepts
13
01101010
– Machine dependent i.e., a code written for one
machine may not run on the other.
– Programming in machine languages is too slow,
tedious, and error-prone.
• Assembly languages
– Symbolic operation codes replaced binary operation
codes; e.g.:
LOAD R1, sessional
LOAD R2, final
Programming Languages Concepts
14
ADD R1, R2
STORE total_marks
– Assembly language programs need to be “assembled” for
execution by the computer. Each assembly language
instruction is translated into one machine language
instruction.
– Very efficient code and easier to write.
• High-level languages
– Closer to English but included simple mathematical
notation; e.g.:
total_marks = sessional + final
Programming Languages Concepts
15
– Programs written in source code which must be
translated into machine language programs called
object code.
– The translation of source code to object code is
accomplished by a machine language system program
called a “compiler”.
16
Broad Categories of Programming
Languages
• Programming languages may be divided into two
(02) broad categories:
– Traditional/Procedural programming languages
» C, BASIC, PASCAL, PYTHON etc.
– Object-oriented programming languages
» C++, C#, JAVA, CURL etc.
17
C Programming Basics C
18
Programming
• C is a programming language developed at AT & T’s
Bell Laboratories of USA in 1972.
• The inventor of the C language is Dennis Ritchie.
• C language is reliable, simple and easy to use.
• Using C, one can develop programs for mobile
phones, microwave ovens, 3D games, and so on.
24
Getting
Started
#include <stdio.h> Pre-processor
#include <conio.h> directive
Function return type
main function
void main(void) Semicolon refers to
string constant the end of statement
c Structure of C Program
{
printf(“This is my first
program in C”);
Program body
getch(); getch function
that keeps output visible on
screen
}
• Function Definition
• Delimiter
c Structure of C Program
• Statement Terminator • The printf() function
• Preprocessor Directive
• Function Definition
– All C Language programs are divided into units called
"Functions".
– A function in C has ( ) at its end. main( ) is always be the
first function to be executed and is the one to which
control is passed when the program is executed.
c Structure of C Program
– The word "void“ preceding the "main" specifies that
the function main( ) will not return a value. The second
"void", in the parenthesis, specifies that the function
takes no arguments.
• Delimiter
– Following the function definition are the braces, which
signals the beginning and end of the body of the
function.
– The opening brace " { " indicates that a block of code
that forms a distinct unit is about to begin.
c Structure of C Program
– The closing brace " } " terminates the block code.
• Statement Terminator
– The line in our program that begins with the word
"printf " is an example of a statement.
– A statement in C Language is terminated with a
semicolon " ; ".
– The C Language pays no attention to any of the
"White Space Character": the carriage
return (newline), the spacebar and the tab key.
c Structure of C Program
– You can put as many or as few white spaces characters
in your program as you like; since they are invisible to
the compiler.
• The printf ( ) function
– The program line printf ("This is my first program in C
Language."); causes the phrase in quotes to be printed
on the screen.
c Structure of C Program
– The word printf is actually a function, just as " main " is
a function name. Since "printf" is a function name,
therefore it is followed by parenthesis.
• The printf ( ) function
– The DevC++ linker looks in the stdio.h file of INCLUDE
directory, finds the section of this file containing printf(
) and causes this section to be linked with the source
program.
c Structure of C Program
– C Language distinguishes between uppercase and
lowercase letters i.e., C language is case sensitive.
– Thus the function PRINTF( ) and Printf( ) are not the
same as the function printf( ).
32
Pre-processor Directives
Pre-processor directive header/include file
#include <stdio.h>
#include <conio.h>
• Program instruction (which end with semicolon) are
instructions to the computer to do something; pre-processor
directives are instruction to the compiler.
• A part of the compiler called the pre-processor deals with
these directives before it begins the real compilation
process.
Exploring the printf() Function
33
• #include tells the compiler to insert another file into your
source file.
• The type file included by #include is called a header/include file
• The printf ( ) function
– The printf() function uses a unique format for printing
constants and variables. For example
void main(void)
{ printf("I am %d years old", 20);
}
Exploring the printf() Function
34
• The printf ( ) function
– The printf() function uses a unique format for printing
constants and variables. For example
void main(void)
{
printf("I am %d years old", 20);
}
Output:
I am 20 years old
Exploring the printf() Function
35
• The function printf() can be given more than one
argument. For example in the above program we
have taken 2 arguments in the printf() function.
• The two arguments are separated by a comma.
• The printf() function takes the vales on the right of
the comma and plugs it into the string on the left.
36
Format Specifiers
• The format specifier tells the printf() where to put
avalue in a string and what format to use in
printing the values.
– In the previous program, the %d tells the printf() to
print the value 20 as a decimal integer.
List of Format Specifiers for printf()
37
Using Format Specifiers in printf()
38
Using Format Specifiers in printf()
39
Using Format Specifiers in printf()
40
void main(void)
{
printf("The letter %c is ", 'j');
printf("pronounced as %s", 'jay');
}
void main(void)
{
Using Format Specifiers in printf()
41
printf("The letter %c is ", 'j');
printf("pronounced as %s", 'jay');
}
Output:
The letter j is pronounced as jay
• In the above program, there are two new
things to note:
Using Format Specifiers in printf()
42
– First we have used %c for printing a character
which is surrounded by single quotes and %s is
used for printing a string which is surrounded by
double quotes.
– This is how C language differentiates between a
character and a string.
• Second thing to note is that even though the
output statement is printed by two separate
program lines, it does not consist of two line of
Using Format Specifiers in printf()
43
text on the out put screen. That is because
printf() does not automatically prints a newline
character at the end of the line.
• So what to do for inserting a newline in a
printf() statement?
• Second thing to note is that even though the
output statement is printed by two separate
program lines, it does not consist of two line of
Using Format Specifiers in printf()
44
text on the out put screen. That is because
printf() does not automatically prints a newline
character at the end of the line.
• So what to do for inserting a newline in a
printf() statement?
void main(void)
{
Using Format Specifiers in printf()
45
printf("The letter %c is n", 'j');
printf("pronounced as %s", 'jay');
}
void main(void)
{
printf("The letter %c is n", 'j');
printf("pronounced as %s", 'jay');
}
Using Format Specifiers in printf()
46
Output:
The letter j is
pronounced as jay
• The above example includes a new symbol, the
' n '.
• In C this means "newline ". The ' n ' has the
effect of a carriage return and linefeed i.e.,
Using Format Specifiers in printf()
47
following ' n ' character, printing is resumed at
the beginning of the next line.
48
Escape Sequences
• Escape sequences allow to control the output of the program
49

More Related Content

What's hot

Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)guest91cc85
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingMalikaJoya
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processorshindept123
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingNeeru Mittal
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1bolovv
 
Language processor
Language processorLanguage processor
Language processorAbha Damani
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction toolsAkhil Kaushik
 
Language processors
Language processorsLanguage processors
Language processorseShikshak
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler designPreeti Katiyar
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler designhari2010
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C LanguageMohamed Elsayed
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compilerMahesh Kumar Chelimilla
 

What's hot (20)

Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Chap 1-language processor
Chap 1-language processorChap 1-language processor
Chap 1-language processor
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 
Compiler1
Compiler1Compiler1
Compiler1
 
Language processor
Language processorLanguage processor
Language processor
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Language processors
Language processorsLanguage processors
Language processors
 
Compiler
Compiler Compiler
Compiler
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Interpreter
InterpreterInterpreter
Interpreter
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compiler
 

Similar to Programming Fundamentals and basic knowledge

Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8kapil078
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translatorsimtiazalijoono
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)mujeeb memon
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: IntroductionEric Chou
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
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].pptxCoolGamer16
 

Similar to Programming Fundamentals and basic knowledge (20)

Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Learn C Language
Learn C LanguageLearn C Language
Learn C Language
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Programming in C
Programming in CProgramming in C
Programming in C
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
C.pdf
C.pdfC.pdf
C.pdf
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translators
 
Rr
RrRr
Rr
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
 
C pdf
C pdfC pdf
C pdf
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: Introduction
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
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
 

More from imtiazalijoono

Embedded systems io programming
Embedded systems   io programmingEmbedded systems   io programming
Embedded systems io programmingimtiazalijoono
 
Embedded systems tools & peripherals
Embedded systems   tools & peripheralsEmbedded systems   tools & peripherals
Embedded systems tools & peripheralsimtiazalijoono
 
Importance of reading and its types.
Importance of reading and its types.Importance of reading and its types.
Importance of reading and its types.imtiazalijoono
 
Negative amplifiers and its types Positive feedback and Negative feedback
Negative amplifiers and its types Positive feedback  and Negative feedbackNegative amplifiers and its types Positive feedback  and Negative feedback
Negative amplifiers and its types Positive feedback and Negative feedbackimtiazalijoono
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierMultistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierimtiazalijoono
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...imtiazalijoono
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development processimtiazalijoono
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions imtiazalijoono
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Conceptsimtiazalijoono
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variableimtiazalijoono
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayimtiazalijoono
 
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,imtiazalijoono
 
Arithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsArithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsimtiazalijoono
 
INTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGINTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGimtiazalijoono
 
FIELD EFFECT TRANSISTERS (FET)
FIELD EFFECT TRANSISTERS (FET)FIELD EFFECT TRANSISTERS (FET)
FIELD EFFECT TRANSISTERS (FET)imtiazalijoono
 

More from imtiazalijoono (20)

Embedded systems io programming
Embedded systems   io programmingEmbedded systems   io programming
Embedded systems io programming
 
Embedded systems tools & peripherals
Embedded systems   tools & peripheralsEmbedded systems   tools & peripherals
Embedded systems tools & peripherals
 
Importance of reading and its types.
Importance of reading and its types.Importance of reading and its types.
Importance of reading and its types.
 
Negative amplifiers and its types Positive feedback and Negative feedback
Negative amplifiers and its types Positive feedback  and Negative feedbackNegative amplifiers and its types Positive feedback  and Negative feedback
Negative amplifiers and its types Positive feedback and Negative feedback
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierMultistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifier
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development process
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Concepts
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variable
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
 
Arithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsArithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operators
 
INTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGINTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMING
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 
FIELD EFFECT TRANSISTERS (FET)
FIELD EFFECT TRANSISTERS (FET)FIELD EFFECT TRANSISTERS (FET)
FIELD EFFECT TRANSISTERS (FET)
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 

Recently uploaded (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 

Programming Fundamentals and basic knowledge

  • 1. 1 Programming Fundamentals Outline • Course introduction • Programming languages concepts • C Programming Basics
  • 2. 2 Course Introduction Course Introduction • Course CHs: – 03 CHs (42 lectures) : Attendance 05 Lab Evaluation Work 15
  • 3. 3 • Theoretical work Maximum Marks 100 Attendance 10 Tests 05 Assignments 05 Mid Semester Examination 20 Final Semester Examination 60 – 1CHs (42 lectures) : • Practical work Semester Lab Examination 30
  • 4. Course Introduction 4 • Recommended Text Book: – Turbo C Programming for the PC » Robert Lafore • Reference Books: – Let Us C, Lates Edition » Yashavant P. Kanetkar – A Book On C » Al Kelley and Ira Pohl • Online Literature/Tutorials etc.
  • 5. Course Introduction 5 • Recommended Tool: – DevC++ • Practical: SD Lab – Class exercises and lab tasks – Assisted by Mr. Shabir Ali Shah • Teaching plan: – 02 tests: • Each after 20TH and 35TH lectures – Assignments
  • 6. Course Introduction 6 • At the end of each book chapter (Robert Lafore) • Assignments are to be collected 1 week after 42nd lecture – Practical exercises: • Almost in each practical • Maintenance of practical • C project • C projects – ATM – Marks Certificate
  • 7. Course Introduction 7 – Traffic Control System – Simple Games – … • Lecture slides/announcements/results can be found at course home page: http://saleem.quest.edu.pk/
  • 8. 8 Important Instructions • During the class: – Keep silent – Turn off mobile phones – No attendance for late comers
  • 9. 9 Programming Languages Concept • What is a programming language? • Why do we need programming languages? • What are the types of programming languages?
  • 10. Programming Languages Concepts 10 • What is a programming language? – A programming language is a set of rules that provides a way of telling a computer how and what operations to perform. • What is a programming language? – The description of a programming language is usually split into the two components of syntax (form) and semantics (meaning).
  • 11. Programming Languages Concepts 11 – A program can execute only if it is both syntactically and semantically correct. • Why do we need programming languages? – Facilitate users in performing tasks which are: 1. Faster, 2. Correct, and 3. Economically cheaper 3. What are the types of programming language?
  • 12. Programming Languages Concepts 12 – Programming languages may be divided into three (03) general types: 1. Machine languages 2. Assembly languages 3. High-level languages • Machine languages – Strings of 0’s and 1’s telling computers to perform basic operations one at a time; e.g.: 01001110 00111001
  • 13. Programming Languages Concepts 13 01101010 – Machine dependent i.e., a code written for one machine may not run on the other. – Programming in machine languages is too slow, tedious, and error-prone. • Assembly languages – Symbolic operation codes replaced binary operation codes; e.g.: LOAD R1, sessional LOAD R2, final
  • 14. Programming Languages Concepts 14 ADD R1, R2 STORE total_marks – Assembly language programs need to be “assembled” for execution by the computer. Each assembly language instruction is translated into one machine language instruction. – Very efficient code and easier to write. • High-level languages – Closer to English but included simple mathematical notation; e.g.: total_marks = sessional + final
  • 15. Programming Languages Concepts 15 – Programs written in source code which must be translated into machine language programs called object code. – The translation of source code to object code is accomplished by a machine language system program called a “compiler”.
  • 16. 16 Broad Categories of Programming Languages • Programming languages may be divided into two (02) broad categories: – Traditional/Procedural programming languages » C, BASIC, PASCAL, PYTHON etc. – Object-oriented programming languages » C++, C#, JAVA, CURL etc.
  • 18. 18 Programming • C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972. • The inventor of the C language is Dennis Ritchie. • C language is reliable, simple and easy to use. • Using C, one can develop programs for mobile phones, microwave ovens, 3D games, and so on.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. 24 Getting Started #include <stdio.h> Pre-processor #include <conio.h> directive Function return type main function void main(void) Semicolon refers to string constant the end of statement
  • 25. c Structure of C Program { printf(“This is my first program in C”); Program body getch(); getch function that keeps output visible on screen } • Function Definition • Delimiter
  • 26. c Structure of C Program • Statement Terminator • The printf() function • Preprocessor Directive • Function Definition – All C Language programs are divided into units called "Functions". – A function in C has ( ) at its end. main( ) is always be the first function to be executed and is the one to which control is passed when the program is executed.
  • 27. c Structure of C Program – The word "void“ preceding the "main" specifies that the function main( ) will not return a value. The second "void", in the parenthesis, specifies that the function takes no arguments. • Delimiter – Following the function definition are the braces, which signals the beginning and end of the body of the function. – The opening brace " { " indicates that a block of code that forms a distinct unit is about to begin.
  • 28. c Structure of C Program – The closing brace " } " terminates the block code. • Statement Terminator – The line in our program that begins with the word "printf " is an example of a statement. – A statement in C Language is terminated with a semicolon " ; ". – The C Language pays no attention to any of the "White Space Character": the carriage return (newline), the spacebar and the tab key.
  • 29. c Structure of C Program – You can put as many or as few white spaces characters in your program as you like; since they are invisible to the compiler. • The printf ( ) function – The program line printf ("This is my first program in C Language."); causes the phrase in quotes to be printed on the screen.
  • 30. c Structure of C Program – The word printf is actually a function, just as " main " is a function name. Since "printf" is a function name, therefore it is followed by parenthesis. • The printf ( ) function – The DevC++ linker looks in the stdio.h file of INCLUDE directory, finds the section of this file containing printf( ) and causes this section to be linked with the source program.
  • 31. c Structure of C Program – C Language distinguishes between uppercase and lowercase letters i.e., C language is case sensitive. – Thus the function PRINTF( ) and Printf( ) are not the same as the function printf( ).
  • 32. 32 Pre-processor Directives Pre-processor directive header/include file #include <stdio.h> #include <conio.h> • Program instruction (which end with semicolon) are instructions to the computer to do something; pre-processor directives are instruction to the compiler. • A part of the compiler called the pre-processor deals with these directives before it begins the real compilation process.
  • 33. Exploring the printf() Function 33 • #include tells the compiler to insert another file into your source file. • The type file included by #include is called a header/include file • The printf ( ) function – The printf() function uses a unique format for printing constants and variables. For example void main(void) { printf("I am %d years old", 20); }
  • 34. Exploring the printf() Function 34 • The printf ( ) function – The printf() function uses a unique format for printing constants and variables. For example void main(void) { printf("I am %d years old", 20); } Output: I am 20 years old
  • 35. Exploring the printf() Function 35 • The function printf() can be given more than one argument. For example in the above program we have taken 2 arguments in the printf() function. • The two arguments are separated by a comma. • The printf() function takes the vales on the right of the comma and plugs it into the string on the left.
  • 36. 36 Format Specifiers • The format specifier tells the printf() where to put avalue in a string and what format to use in printing the values. – In the previous program, the %d tells the printf() to print the value 20 as a decimal integer. List of Format Specifiers for printf()
  • 39. 39
  • 40. Using Format Specifiers in printf() 40 void main(void) { printf("The letter %c is ", 'j'); printf("pronounced as %s", 'jay'); } void main(void) {
  • 41. Using Format Specifiers in printf() 41 printf("The letter %c is ", 'j'); printf("pronounced as %s", 'jay'); } Output: The letter j is pronounced as jay • In the above program, there are two new things to note:
  • 42. Using Format Specifiers in printf() 42 – First we have used %c for printing a character which is surrounded by single quotes and %s is used for printing a string which is surrounded by double quotes. – This is how C language differentiates between a character and a string. • Second thing to note is that even though the output statement is printed by two separate program lines, it does not consist of two line of
  • 43. Using Format Specifiers in printf() 43 text on the out put screen. That is because printf() does not automatically prints a newline character at the end of the line. • So what to do for inserting a newline in a printf() statement? • Second thing to note is that even though the output statement is printed by two separate program lines, it does not consist of two line of
  • 44. Using Format Specifiers in printf() 44 text on the out put screen. That is because printf() does not automatically prints a newline character at the end of the line. • So what to do for inserting a newline in a printf() statement? void main(void) {
  • 45. Using Format Specifiers in printf() 45 printf("The letter %c is n", 'j'); printf("pronounced as %s", 'jay'); } void main(void) { printf("The letter %c is n", 'j'); printf("pronounced as %s", 'jay'); }
  • 46. Using Format Specifiers in printf() 46 Output: The letter j is pronounced as jay • The above example includes a new symbol, the ' n '. • In C this means "newline ". The ' n ' has the effect of a carriage return and linefeed i.e.,
  • 47. Using Format Specifiers in printf() 47 following ' n ' character, printing is resumed at the beginning of the next line.
  • 48. 48 Escape Sequences • Escape sequences allow to control the output of the program
  • 49. 49