SlideShare a Scribd company logo
1 of 49
Programming Fundamentals
Week 1A
CS-102
The Course Objectives
Contents
• Introduction to C Programming Language
• History
• Simple Program
• Explanation of the Code
• IDE: Dev C++
• Algorithm Writing & Logic Development
• Algorithm
• Writing an algorithm
• Logic
• Developing Logic
• Flowchart Basics
• Shapes
• Flow
• Symbols & Tutorial
• IDE: Visio, creately.com
Introduction to C Programming
• The C language facilitates a structured and disciplined approach to computer
program design.
• Created in 1972 to write operating systems (Unix in particular)
• By Dennis Ritchie
• Bell Labs
• Evolved from B
• Can be portable to other hardware (with careful design – use Plauger’s The
Standard C Library book)
• Built for performance and memory management – operating systems, embedded
systems, real-time systems, communication systems
• It is usually used for programming Microcontrollers
• C language natively doesn't support class but has structures
Brief History of development
• All history available here
• 1989 ANSI and ISO -> Standard C
• 1999 C99
• 2011 C11
• Don’t get thrown when you lookup information on websites and find
conflicts based upon standards
• 1979 C++ by Bjarn Stroustrup also at Bell
• Object orientation
• 1991 Java by Sun
• Partial compile to java bytecode: virtual machine code
• Write once, run anywhere
• Memory manager – garbage collection
• Many JVMs written in C / C++
Compiler, Interpreter and Assembler
Compilers
• A compiler takes the source code as a whole and translates it into object code all in one go. Once
converted, the object code can be run at any time. This process is called compilation. C uses
compiler.
Interpreters
• An interpreter translates source code into object code one instruction at a time. It is similar to a
human translator translating what a person says into another language, sentence by sentence.
The resulting object code is then executed immediately. The process is called interpretation.
Assemblers
• Assemblers are a third type of translator. The purpose of an assembler is to translate assembly
language into object code. Whereas compilers and interpreters generate many machine
code instructions for each high-level instruction, assemblers create one machine code instruction
for each assembly instruction.
• Learn more here
Loader
Loader
• A loader is a piece of software that is responsible for loading
executable files into memory to enable the central processing unit
(CPU) to run them. It calculates the size of a program and dedicates
enough memory space for it to run efficiently.
Syntax and Symantec Error
• Syntax is not following the rules of a language
• I eating apple
• A=X+-B
• 2+2=2 (in c language)
• Symantec is following language rules but writing a wrong logic
• One dozen of milk
• Two and two makes five
Simple Program in C
Explanation
A Simple C Program: Printing a Line of Text (Cont.)
• Lines 1 and 2
• /* Fig. 2.1: fig02_01.c
A first program in C */
• begin with /* and end with */ indicating that these two lines are a
comment.
• You insert comments to document programs and improve program
readability.
• Comments do not cause the computer to perform any action when the
program is run.
A Simple C Program: Printing a Line of Text
(Cont.)
• Comments are ignored by the C compiler and do not cause any
machine-language object code to be generated.
• Comments also help other people read and understand your program.
A Simple C Program: Printing a Line of Text
(Cont.)
• C99 also includes the C++ language’s // single-line comments in which
everything from // to the end of the line is a comment.
• These can be used as standalone comments on lines by themselves or as end-
of-line comments to the right of a partial line of code.
• Some programmers prefer // comments because they’re shorter and they
eliminate the common programming errors that occur with /* */ comments.
• Line 3
• #include <stdio.h>
• is a directive to the C preprocessor.
A Simple C Program: Printing a Line of Text
(Cont.)
• Lines beginning with # are processed by the preprocessor before the program
is compiled.
• Line 3 tells the preprocessor to include the contents of the standard
input/output header (<stdio.h>) in the program.
• This header contains information used by the compiler when compiling calls to
standard input/output library functions such as printf.
• Line 6
• int main( void )
• is a part of every C program.
• The parentheses after main indicate that main is a program building block
called a function.
A Simple C Program: Printing a Line of Text
(Cont.)
• C programs contain one or more functions, one of which must be
main.
• Every program in C begins executing at the function main.
• The keyword int to the left of main indicates that main “returns”
an integer (whole number) value.
• We’ll explain what it means for a function to “return a value” when we
demonstrate how to create your own functions in Chapter 5.
A Simple C Program: Printing a Line of Text
(Cont.)
• For now, simply include the keyword int to the left of main in each
of your programs.
• Functions also can receive information when they’re called upon to
execute.
• The void in parentheses here means that main does not receive any
information.
A Simple C Program: Printing a Line of Text
(Cont.)
• A left brace, {, begins the body of every function (line 7).
• A corresponding right brace ends each function (line 11).
• This pair of braces and the portion of the program between the braces is called
a block.
• Line 8
• printf( "Welcome to C!n" );
• instructs the computer to perform an action, namely to print on the screen the
string of characters marked by the quotation marks.
• A string is sometimes called a character string, a message or a literal.
A Simple C Program: Printing a Line of Text
(Cont.)
• The entire line, including printf, its argument within the parentheses and
the semicolon (;), is called a statement.
• Every statement must end with a semicolon (also known as the statement
terminator).
• When the preceding printf statement is executed, it prints the message
Welcome to C! on the screen.
• The characters normally print exactly as they appear between the double
quotes in the printf statement.
• Notice that the characters n were not printed on the screen.
• The backslash () is called an escape character.
• It indicates that printf is supposed to do something out of the ordinary.
A Simple C Program: Printing a Line of Text
(Cont.)
• When encountering a backslash in a string, the compiler looks ahead at
the next character and combines it with the backslash to form an
escape sequence.
• The escape sequence n means newline.
• When a newline appears in the string output by a printf, the
newline causes the cursor to position to the beginning of the next line
on the screen.
• Some common escape sequences are listed in Fig. .
A Simple C Program: Printing a Line of Text
(Cont.)
• Because the backslash has special meaning in a string, i.e., the
compiler recognizes it as an escape character, we use a double
backslash () to place a single backslash in a string.
• Printing a double quote also presents a problem because double quotes
mark the boundary of a string—such quotes are not printed.
• By using the escape sequence " in a string to be output by printf,
we indicate that printf should display a double quote.
A Simple C Program: Printing a Line of Text
(Cont.)
• Line 10
• return 0; /* indicate that program ended successfully */
• is included at the end of every main function.
• The keyword return is one of several means we’ll use to exit a
function.
• When the return statement is used at the end of main as shown here,
the value 0 indicates that the program has terminated successfully.
• The right brace, }, (line 12) indicates that the end of main has been
reached.
A Simple C Program: Printing a Line of Text
(Cont.)
• We said that printf causes the computer to perform an action.
• As any program executes, it performs a variety of actions and makes
decisions.
• In Chapter 3, we discuss this action/decision model of programming in
depth.
A Simple C Program: Printing a Line of Text
(Cont.)
• Standard library functions like printf and scanf are not part of the C
programming language.
• For example, the compiler cannot find a spelling error in printf or scanf.
• When the compiler compiles a printf statement, it merely provides space in
the object program for a “call” to the library function.
• But the compiler does not know where the library functions are—the linker
does.
• When the linker runs, it locates the library functions and inserts the proper
calls to these library functions in the object program.
A Simple C Program: Printing a Line of Text
(Cont.)
• Now the object program is complete and ready to be executed.
• For this reason, the linked program is called an executable.
• If the function name is misspelled, it’s the linker that will spot the
error, because it will not be able to match the name in the C program
with the name of any known function in the libraries.
A Simple C Program: Printing a Line of Text
(Cont.)
• The printf function can print Welcome to C! several different
ways.
• For example, the program of Fig. 2.3 produces the same output as the
program of Fig. 2.1.
• This works because each printf resumes printing where the
previous printf stopped printing.
• The first printf (line 8) prints Welcome followed by a space and
the second printf (line 9) begins printing on the same line
immediately following the space.
A Simple C Program: Printing a Line of Text
(Cont.)
• One printf can print several lines by using additional newline
characters as in Fig. 2.4.
• Each time the n (newline) escape sequence is encountered, output
continues at the beginning of the next line.
Integrated Development Environment (IDE)
• https://www.bloodshed.net/
• Contains support for both C and C++
• Turbo C can also be used: https://turbo-c.apponic.com/
• Online Environment: https://www.onlinegdb.com/online_c_compiler
Algorithm writing and Logic Development
• In mathematics and computer science, an algorithm is a finite
sequence of well-defined, computer-implementable instructions,
typically to solve a class of problems or to perform a computation.
• Algorithms are always unambiguous and are used as specifications for
performing
1. Calculations
2. data processing
3. automated reasoning
and other tasks.
Simple Algorithm
• Adding two number
• Find a page
• Write first number
• Write second number below first number while taking care of digit and
decimal places
• Add the first digit places
• Add the portion as carry to the second digit place if the sum of these is
greater than 9
• Else, write the number as added.
• Continue till there is no number on the right side of the numbers.
Logic
• Logic is the theory behind any program that will be executed
• Logic can be wrong or write, In either case, the program will run
• Sometimes we think that the logic is correct from certain outputs but
in actual it is not
• Logic is very different from Logic Programming
• A logic behind a program is called complete logic if the it specifies all
the condition that are probable to be happen, then, if not now.
Logic and Algorithm
• The statements of logic are termed as algorithm
• Executing any idea required certain steps. Each of these steps are
termed as logical statements.
• Algorithm is the set of instructions (logical steps) that are to be
followed for executing a certain task
Making a picnic program (developing logic)
• Select a place (it should be reachable within dates)
• Find the commute (in budget and fastest)
• Find the costs (minimize each events cost so that it is at least
affordable)
• Select friends who will go (those who are willing to go and free)
• Fix the dates and timing (manageable timing and durations)
• Decide tasks that will be performed on going, staying, coming back
• Bring, inform, plan or buy ingredients for each task/event
• Create and execution Plan (the logical steps to follow)
Execution plan
• If the date is due
• Call your one friend to bring car
• Call other friends to come to a single meet point
• Put the tents, edibles and other stuff in the trunk
• Fuel it enough to reach the destination
• Build the camp
• Do photography
• Prepare the meal and eat it
• Night Photography or Music
• Sleep
• Roam in the locality all day
• Repeat Task X:
• Go back to Home city
• Drop off all friends
• Calculate and share expenses
Task X:
Flow Charting
• A flowchart is a diagram that depicts the “flow” of a program.
• The figure shown here is a flowchart for the pay-calculating
program shown.
• A flow chart can be Programming Flow chart or it can be
process flowchart in which you may see different images or clip
arts etc. Such chart is known as composite flow chart.
START
Display message “How many
hours did you work?”
Read Hours
Display message “How much do
you get paid per hour?”
Read PayRate
Multiply Hours by PayRate.
Store result in GrossPay.
Display GrossPay
END
Basic Symbols
• Terminals
• Processes
• Decisions
• Input/output
Terminals
• Start and End are termed as terminals
• represented by rounded rectangles
• indicate a starting or ending point
START
END
Processes
Process is a task done in a program/algorithm
• Represented by rectangles
• Indicates a process such as a mathematical computation or variable
assignment
Multiply Hours
by PayRate.
Store result in
GrossPay.
Decisions
Decision leads a program/algorithm to go on certain way
If,
then
Input/output
It represents the requirements of a program or displays certain data
• Represented by parallelograms
• indicate an input or output operation
Display message
“How many
hours did you
work?”
Read Hours
Four types of flow
• Sequence
• Decision
• Repetition
• Case
Sequence Structure
• A series of actions are performed in sequence
• The pay-calculating example was a sequence flowchart.
41
Decision Structure
• The flowchart segment below shows how a decision structure is expressed in C++
as an if/else statement.
42
YESNO
x < y?
Calculate a
as x times 2.
Calculate a
as x plus y.
if (x < y)
a = x * 2;
else
a = x + y;
Flowchart C Code
Decision Structure
• The flowchart segment below shows a decision structure with only one action to
perform. It is expressed as an if statement in C++ code.
43
if (x < y)
a = x * 2;
Flowchart C Code
YESNO
x < y?
Calculate a
as x times 2.
Repetition Structure
• The flowchart segment below shows a repetition structure expressed in C as a
while loop.
44
while (x < y)
x++;
Flowchart C Code
x < y? Add 1 to x
YES
Controlling a Repetition Structure
• The action performed by a repetition structure must eventually cause the loop to
terminate. Otherwise, an infinite loop is created.
• In this flowchart segment, x is never changed. Once the loop starts, it will never
end.
• QUESTION: How can this
flowchart be modified so
it is no longer an infinite
loop?
45
x < y? Display x
YES
Controlling a Repetition Structure
• ANSWER: By adding an action within the repetition that changes the value of x.
46
x < y? Display x Add 1 to x
YES
Case Structure
47
CASE
years_employed
1 2 3 Other
bonus = 100 bonus = 200 bonus = 400 bonus = 800
If years_employed = 1,
bonus is set to 100
If years_employed = 2,
bonus is set to 200
If years_employed = 3,
bonus is set to 400
If years_employed is
any other value, bonus
is set to 800
IDE for Flow chart
• http://www.creately.com/
• Microsoft Visio (Office365 service) PAID/Crack
Thanks

More Related Content

What's hot

Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environmentJohn Paul Espino
 
Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Ibrahim Elewah
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAkshay Ithape
 
Input output in c
Input output in cInput output in c
Input output in cDucat
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
C introduction
C introductionC introduction
C introductionKamran
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Shivang Bajaniya
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Shipra Swati
 
C programming introduction
C programming introductionC programming introduction
C programming introductionDucat
 
[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++Muhammad Hammad Waseem
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingNeeru Mittal
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEMMansi Tyagi
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)indrasir
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGJEENA SARA VIJU
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTBatra Centre
 

What's hot (20)

Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environment
 
Computer programming chapter ( 4 )
Computer programming chapter ( 4 ) Computer programming chapter ( 4 )
Computer programming chapter ( 4 )
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Input output in c
Input output in cInput output in c
Input output in c
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
C introduction
C introductionC introduction
C introduction
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
C programming introduction
C programming introductionC programming introduction
C programming introduction
 
[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Book ppt
Book pptBook ppt
Book ppt
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
 
Unit4
Unit4Unit4
Unit4
 

Similar to C Programming Fundamentals: Introduction to C Language

Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIBlue Elephant Consulting
 
PROGRAMMING IN C - SARASWATHI RAMALINGAM
PROGRAMMING IN C - SARASWATHI RAMALINGAMPROGRAMMING IN C - SARASWATHI RAMALINGAM
PROGRAMMING IN C - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge imtiazalijoono
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
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
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
Lecture01
Lecture01Lecture01
Lecture01Xafran
 
C and its errors
C and its errorsC and its errors
C and its errorsJunaid Raja
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C FundamentalsSzeChingChen
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8kapil078
 

Similar to C Programming Fundamentals: Introduction to C Language (20)

Intro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample ProgramIntro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample Program
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
 
PROGRAMMING IN C - SARASWATHI RAMALINGAM
PROGRAMMING IN C - SARASWATHI RAMALINGAMPROGRAMMING IN C - SARASWATHI RAMALINGAM
PROGRAMMING IN C - SARASWATHI RAMALINGAM
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
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
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Lecture01
Lecture01Lecture01
Lecture01
 
C and its errors
C and its errorsC and its errors
C and its errors
 
C language tutorial
C language tutorialC language tutorial
C language tutorial
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C Fundamentals
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
C intro
C introC intro
C intro
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
cmp104 lec 8
cmp104 lec 8cmp104 lec 8
cmp104 lec 8
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

More from Jawad Khan

2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in cJawad Khan
 
2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logicsJawad Khan
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentalsJawad Khan
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instrumentsJawad Khan
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)Jawad Khan
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)Jawad Khan
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridgesJawad Khan
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meterJawad Khan
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instrumentsJawad Khan
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement systemJawad Khan
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+Jawad Khan
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audioJawad Khan
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audioJawad Khan
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3Jawad Khan
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2Jawad Khan
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1Jawad Khan
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversionJawad Khan
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examplesJawad Khan
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuitsJawad Khan
 
1. magnetic coupled circuits
1. magnetic coupled circuits1. magnetic coupled circuits
1. magnetic coupled circuitsJawad Khan
 

More from Jawad Khan (20)

2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in c
 
2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logics
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridges
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meter
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instruments
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement system
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audio
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audio
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversion
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examples
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuits
 
1. magnetic coupled circuits
1. magnetic coupled circuits1. magnetic coupled circuits
1. magnetic coupled circuits
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

C Programming Fundamentals: Introduction to C Language

  • 3. Contents • Introduction to C Programming Language • History • Simple Program • Explanation of the Code • IDE: Dev C++ • Algorithm Writing & Logic Development • Algorithm • Writing an algorithm • Logic • Developing Logic • Flowchart Basics • Shapes • Flow • Symbols & Tutorial • IDE: Visio, creately.com
  • 4. Introduction to C Programming • The C language facilitates a structured and disciplined approach to computer program design. • Created in 1972 to write operating systems (Unix in particular) • By Dennis Ritchie • Bell Labs • Evolved from B • Can be portable to other hardware (with careful design – use Plauger’s The Standard C Library book) • Built for performance and memory management – operating systems, embedded systems, real-time systems, communication systems • It is usually used for programming Microcontrollers • C language natively doesn't support class but has structures
  • 5. Brief History of development • All history available here • 1989 ANSI and ISO -> Standard C • 1999 C99 • 2011 C11 • Don’t get thrown when you lookup information on websites and find conflicts based upon standards • 1979 C++ by Bjarn Stroustrup also at Bell • Object orientation • 1991 Java by Sun • Partial compile to java bytecode: virtual machine code • Write once, run anywhere • Memory manager – garbage collection • Many JVMs written in C / C++
  • 6. Compiler, Interpreter and Assembler Compilers • A compiler takes the source code as a whole and translates it into object code all in one go. Once converted, the object code can be run at any time. This process is called compilation. C uses compiler. Interpreters • An interpreter translates source code into object code one instruction at a time. It is similar to a human translator translating what a person says into another language, sentence by sentence. The resulting object code is then executed immediately. The process is called interpretation. Assemblers • Assemblers are a third type of translator. The purpose of an assembler is to translate assembly language into object code. Whereas compilers and interpreters generate many machine code instructions for each high-level instruction, assemblers create one machine code instruction for each assembly instruction. • Learn more here
  • 7. Loader Loader • A loader is a piece of software that is responsible for loading executable files into memory to enable the central processing unit (CPU) to run them. It calculates the size of a program and dedicates enough memory space for it to run efficiently.
  • 8. Syntax and Symantec Error • Syntax is not following the rules of a language • I eating apple • A=X+-B • 2+2=2 (in c language) • Symantec is following language rules but writing a wrong logic • One dozen of milk • Two and two makes five
  • 11. A Simple C Program: Printing a Line of Text (Cont.) • Lines 1 and 2 • /* Fig. 2.1: fig02_01.c A first program in C */ • begin with /* and end with */ indicating that these two lines are a comment. • You insert comments to document programs and improve program readability. • Comments do not cause the computer to perform any action when the program is run.
  • 12. A Simple C Program: Printing a Line of Text (Cont.) • Comments are ignored by the C compiler and do not cause any machine-language object code to be generated. • Comments also help other people read and understand your program.
  • 13. A Simple C Program: Printing a Line of Text (Cont.) • C99 also includes the C++ language’s // single-line comments in which everything from // to the end of the line is a comment. • These can be used as standalone comments on lines by themselves or as end- of-line comments to the right of a partial line of code. • Some programmers prefer // comments because they’re shorter and they eliminate the common programming errors that occur with /* */ comments. • Line 3 • #include <stdio.h> • is a directive to the C preprocessor.
  • 14. A Simple C Program: Printing a Line of Text (Cont.) • Lines beginning with # are processed by the preprocessor before the program is compiled. • Line 3 tells the preprocessor to include the contents of the standard input/output header (<stdio.h>) in the program. • This header contains information used by the compiler when compiling calls to standard input/output library functions such as printf. • Line 6 • int main( void ) • is a part of every C program. • The parentheses after main indicate that main is a program building block called a function.
  • 15. A Simple C Program: Printing a Line of Text (Cont.) • C programs contain one or more functions, one of which must be main. • Every program in C begins executing at the function main. • The keyword int to the left of main indicates that main “returns” an integer (whole number) value. • We’ll explain what it means for a function to “return a value” when we demonstrate how to create your own functions in Chapter 5.
  • 16. A Simple C Program: Printing a Line of Text (Cont.) • For now, simply include the keyword int to the left of main in each of your programs. • Functions also can receive information when they’re called upon to execute. • The void in parentheses here means that main does not receive any information.
  • 17. A Simple C Program: Printing a Line of Text (Cont.) • A left brace, {, begins the body of every function (line 7). • A corresponding right brace ends each function (line 11). • This pair of braces and the portion of the program between the braces is called a block. • Line 8 • printf( "Welcome to C!n" ); • instructs the computer to perform an action, namely to print on the screen the string of characters marked by the quotation marks. • A string is sometimes called a character string, a message or a literal.
  • 18. A Simple C Program: Printing a Line of Text (Cont.) • The entire line, including printf, its argument within the parentheses and the semicolon (;), is called a statement. • Every statement must end with a semicolon (also known as the statement terminator). • When the preceding printf statement is executed, it prints the message Welcome to C! on the screen. • The characters normally print exactly as they appear between the double quotes in the printf statement. • Notice that the characters n were not printed on the screen. • The backslash () is called an escape character. • It indicates that printf is supposed to do something out of the ordinary.
  • 19. A Simple C Program: Printing a Line of Text (Cont.) • When encountering a backslash in a string, the compiler looks ahead at the next character and combines it with the backslash to form an escape sequence. • The escape sequence n means newline. • When a newline appears in the string output by a printf, the newline causes the cursor to position to the beginning of the next line on the screen. • Some common escape sequences are listed in Fig. .
  • 20. A Simple C Program: Printing a Line of Text (Cont.) • Because the backslash has special meaning in a string, i.e., the compiler recognizes it as an escape character, we use a double backslash () to place a single backslash in a string. • Printing a double quote also presents a problem because double quotes mark the boundary of a string—such quotes are not printed. • By using the escape sequence " in a string to be output by printf, we indicate that printf should display a double quote.
  • 21. A Simple C Program: Printing a Line of Text (Cont.) • Line 10 • return 0; /* indicate that program ended successfully */ • is included at the end of every main function. • The keyword return is one of several means we’ll use to exit a function. • When the return statement is used at the end of main as shown here, the value 0 indicates that the program has terminated successfully. • The right brace, }, (line 12) indicates that the end of main has been reached.
  • 22. A Simple C Program: Printing a Line of Text (Cont.) • We said that printf causes the computer to perform an action. • As any program executes, it performs a variety of actions and makes decisions. • In Chapter 3, we discuss this action/decision model of programming in depth.
  • 23. A Simple C Program: Printing a Line of Text (Cont.) • Standard library functions like printf and scanf are not part of the C programming language. • For example, the compiler cannot find a spelling error in printf or scanf. • When the compiler compiles a printf statement, it merely provides space in the object program for a “call” to the library function. • But the compiler does not know where the library functions are—the linker does. • When the linker runs, it locates the library functions and inserts the proper calls to these library functions in the object program.
  • 24. A Simple C Program: Printing a Line of Text (Cont.) • Now the object program is complete and ready to be executed. • For this reason, the linked program is called an executable. • If the function name is misspelled, it’s the linker that will spot the error, because it will not be able to match the name in the C program with the name of any known function in the libraries.
  • 25. A Simple C Program: Printing a Line of Text (Cont.) • The printf function can print Welcome to C! several different ways. • For example, the program of Fig. 2.3 produces the same output as the program of Fig. 2.1. • This works because each printf resumes printing where the previous printf stopped printing. • The first printf (line 8) prints Welcome followed by a space and the second printf (line 9) begins printing on the same line immediately following the space.
  • 26. A Simple C Program: Printing a Line of Text (Cont.) • One printf can print several lines by using additional newline characters as in Fig. 2.4. • Each time the n (newline) escape sequence is encountered, output continues at the beginning of the next line.
  • 27. Integrated Development Environment (IDE) • https://www.bloodshed.net/ • Contains support for both C and C++ • Turbo C can also be used: https://turbo-c.apponic.com/ • Online Environment: https://www.onlinegdb.com/online_c_compiler
  • 28. Algorithm writing and Logic Development • In mathematics and computer science, an algorithm is a finite sequence of well-defined, computer-implementable instructions, typically to solve a class of problems or to perform a computation. • Algorithms are always unambiguous and are used as specifications for performing 1. Calculations 2. data processing 3. automated reasoning and other tasks.
  • 29. Simple Algorithm • Adding two number • Find a page • Write first number • Write second number below first number while taking care of digit and decimal places • Add the first digit places • Add the portion as carry to the second digit place if the sum of these is greater than 9 • Else, write the number as added. • Continue till there is no number on the right side of the numbers.
  • 30. Logic • Logic is the theory behind any program that will be executed • Logic can be wrong or write, In either case, the program will run • Sometimes we think that the logic is correct from certain outputs but in actual it is not • Logic is very different from Logic Programming • A logic behind a program is called complete logic if the it specifies all the condition that are probable to be happen, then, if not now.
  • 31. Logic and Algorithm • The statements of logic are termed as algorithm • Executing any idea required certain steps. Each of these steps are termed as logical statements. • Algorithm is the set of instructions (logical steps) that are to be followed for executing a certain task
  • 32. Making a picnic program (developing logic) • Select a place (it should be reachable within dates) • Find the commute (in budget and fastest) • Find the costs (minimize each events cost so that it is at least affordable) • Select friends who will go (those who are willing to go and free) • Fix the dates and timing (manageable timing and durations) • Decide tasks that will be performed on going, staying, coming back • Bring, inform, plan or buy ingredients for each task/event • Create and execution Plan (the logical steps to follow)
  • 33. Execution plan • If the date is due • Call your one friend to bring car • Call other friends to come to a single meet point • Put the tents, edibles and other stuff in the trunk • Fuel it enough to reach the destination • Build the camp • Do photography • Prepare the meal and eat it • Night Photography or Music • Sleep • Roam in the locality all day • Repeat Task X: • Go back to Home city • Drop off all friends • Calculate and share expenses Task X:
  • 34. Flow Charting • A flowchart is a diagram that depicts the “flow” of a program. • The figure shown here is a flowchart for the pay-calculating program shown. • A flow chart can be Programming Flow chart or it can be process flowchart in which you may see different images or clip arts etc. Such chart is known as composite flow chart. START Display message “How many hours did you work?” Read Hours Display message “How much do you get paid per hour?” Read PayRate Multiply Hours by PayRate. Store result in GrossPay. Display GrossPay END
  • 35. Basic Symbols • Terminals • Processes • Decisions • Input/output
  • 36. Terminals • Start and End are termed as terminals • represented by rounded rectangles • indicate a starting or ending point START END
  • 37. Processes Process is a task done in a program/algorithm • Represented by rectangles • Indicates a process such as a mathematical computation or variable assignment Multiply Hours by PayRate. Store result in GrossPay.
  • 38. Decisions Decision leads a program/algorithm to go on certain way If, then
  • 39. Input/output It represents the requirements of a program or displays certain data • Represented by parallelograms • indicate an input or output operation Display message “How many hours did you work?” Read Hours
  • 40. Four types of flow • Sequence • Decision • Repetition • Case
  • 41. Sequence Structure • A series of actions are performed in sequence • The pay-calculating example was a sequence flowchart. 41
  • 42. Decision Structure • The flowchart segment below shows how a decision structure is expressed in C++ as an if/else statement. 42 YESNO x < y? Calculate a as x times 2. Calculate a as x plus y. if (x < y) a = x * 2; else a = x + y; Flowchart C Code
  • 43. Decision Structure • The flowchart segment below shows a decision structure with only one action to perform. It is expressed as an if statement in C++ code. 43 if (x < y) a = x * 2; Flowchart C Code YESNO x < y? Calculate a as x times 2.
  • 44. Repetition Structure • The flowchart segment below shows a repetition structure expressed in C as a while loop. 44 while (x < y) x++; Flowchart C Code x < y? Add 1 to x YES
  • 45. Controlling a Repetition Structure • The action performed by a repetition structure must eventually cause the loop to terminate. Otherwise, an infinite loop is created. • In this flowchart segment, x is never changed. Once the loop starts, it will never end. • QUESTION: How can this flowchart be modified so it is no longer an infinite loop? 45 x < y? Display x YES
  • 46. Controlling a Repetition Structure • ANSWER: By adding an action within the repetition that changes the value of x. 46 x < y? Display x Add 1 to x YES
  • 47. Case Structure 47 CASE years_employed 1 2 3 Other bonus = 100 bonus = 200 bonus = 400 bonus = 800 If years_employed = 1, bonus is set to 100 If years_employed = 2, bonus is set to 200 If years_employed = 3, bonus is set to 400 If years_employed is any other value, bonus is set to 800
  • 48. IDE for Flow chart • http://www.creately.com/ • Microsoft Visio (Office365 service) PAID/Crack