SlideShare a Scribd company logo
1 of 11
SESSION NUMBER: 02
Session Outcome: At the end of this session on ALGORITHMS AND FLOWCHARTS, Students will be able:
1. To design algorithms for conditional problems.
2. To design flowcharts for iterativeproblems.
Ex 1. Write an algorithmanddraw flowchart to findwhetherpersoniseligibleforvote ornot(above
18 eligible).
Solution:
1. Identifythe inputstobe giventovoteEligibilityfunction ( here itisage )
2. Identifythe outputtobe printedonmonitor (here itis Eligible ornotEligible)
Algorithmfor main() function:
Step1: Start
Step2: age:=20
Step3: Call voteEligibility(age) function
Step4: Stop
Algorithmfor voteEligibility(intage) function:
Step1: Start
Step2: if( age >= 18) then
print“Eligible to Vote”
Step3: else
print“Not eligible toVote”
Step4: returnto main()
Flowchart:
Code:
#include<stdio.h> // headerfile
voidVoteEligibility(int); // functionprototype
intmain()
{
intage;
age = 20;
voteEligibility(age); // functioncall
return0;
}
voidvoteEligibility(intage) //functionbodybeginshere
{
if(age>=18)
{
printf("Eligibletovote");
}
else
{
printf("NotEligible tovote");
}
return;
}
Here in the above
program,we have to
write #include<stdio.h>
stdioisthe short formfor standardinputand output
stdio.hisan headerfile.
A headerfile containsmanyfunctions.
Some of the available functionsinheaderfilestdio.hare printf,scanf,etc.
// are comments. Commentswill enable youtounderstandthe code.Whateveryouwrite after//are not
executedbythe compiler.
intmain() Executionof Cprogram starts frommain() andit isan inbuiltmethod
voidVoteEligibility(int); Functionprototype indicatesthe returntype of function, functionname,inputparameters
and theirdatatypes
intage; a memoryisallocatedandname giventomemorylocationisage. Here age iscalleda
variable.A namedmemorylocationiscalledavariable
intis a data type indicatingthatwe can store integervaluesinage memorylocation.
The range of valuesthatcan be storedinan integervariable,age is -32767 to 32768 in a 32-
bitcomputer
age=20; will putvalue 20 inthe age memorylocation.
voteEligibility(age); main() callsthe function voteEligibility(age); main() pausesexecution
CPU starts executingVoteEligibility(age);function
voidvoteEligibility(intage)
{
The userdefinedfunctionvoteEligibility(intage) isgivenfunctionalityhere.Itiscalleduser
definedfunctionas thisfunctioniswrittenbyprogrammer.Butprintf()functioniscalled
inbuiltfunctionasthe code forprintf() iswrittenbysome one else andwe are usingit.
{ indicate the functionbeginshere,inotherwords,the functionblockbeginsher
if(age>=18)
{
If is an conditional statementasitchecksa conditionage >= 18. if the conditionistrue
then{ indicatesbeginningof if block.all the statementsinside{ and} of if blockwill be
executed
Alsohere age referstothe valuespresentinage memorylocation.
If is a keywordasit has some special meaning
printf("Eligibletovote");
}
printf will printthe message “Eligible tovote”onthe monitor.
} indicatesendof if block
printf isan inbuiltfunctioninstdio.h
else
{
else mustbe writtenafterthe if blockandwill be executedif the conditionage>=18
becomesfalse.i.e,the value insideage memorylocationisnotgreaterthan18 thenelse
blockwill execute
else isalsoa keyword
printf("Eligibletovote");
}
All the statementsinside else blockwill be executedif the conditionage>=18 isfalse
return will enable youtocome outof the voteEligibilityfunctionandreturntothe main() where
thisfunctionwascalled
} End of voteEligibility functionblock
return0; main() functionreturns0to compilerindicatingthe programexecutedsuccessfully
} End of main() function
Example 2:
Use an algorithmtoprintall natural numbersfrom1 to N to make the studentsunderstanddesignof
algorithmsandflowchartfor iterative problems.
Solution:
1. Identifythe inputstobe giventoPrintmethod( here itis n)
2. Identifythe outputtobe printedonmonitor(all natural numbersfrom1 to n)
Algorithmfor main() function:
Step1: Start
Step2: n:=20
Step3: Call Print(n) function
Step4: Stop
Algorithmfor Print(n) function:
Step1: Start
Step2: i := 1
Step3: if ( i <= n) then
Step3.1 : printi
Step3.2: i := i+1
Step3.3: go to step3
Step4: returnto main()
Flowchart:
main() print(intn)
Here the main() methodpausesandthe CPU control goesto print(intn)
Here the CPU control goesback to main()
Start
n := 20
Print(n)
Stop
Print(intn)
i <= n
print i
i := 1
i := i+1
True
False
Code:
#include<stdio.h>
voidPrint(int);
intmain()
{
intn=20;
Print(n);
return0;
}
voidPrint(intn)
{
inti = 1;
while(i<=n)
{
printf("%d",i);
i=i+1;
}
}
Practice SessionProblems:
Q1) Write an algorithmanddraw flowchart tofind biggestof giventwonumber.
Algorithmfor main() function:
Step1: Start
Step2: n1:=10
Step3: n2 := 20
Step4: biggest_number:=calculateBig(n1,n2)
Step5: printbiggest_number
Step6: Stop
Algorithmfor calculateBig(intn1, int n2) function:
Step1: Start
Step2: if( n1 >= n2) then
big:= n1
Step3: else
big:= n2
Step4: returnbig
FlowChart:
Q2) Write an algorithmanddraw flowchart tofindthe biggestof given3 distinctnumbers.
Algorithmfor main() function:
Step1: Start
Step2 : n1 := 10
Step3 : n2 := 20
Step4 : n3 := 30
Step5: ans=calculateBig(n1,n2,n3)
Step6: printans
Step7: Stop
Algorithmfor calculateBig(intn1, int n2, int n3) function:
Step1: Start
Step2 : if n1 > n2 then
Step2.1: if n1 > n3 then
big:= n1
Step2.2: else
big:= n3
Step3: else
Step3.1 if n2 > n3 then
big:= n2
Step3.2 else
big:= n3
Step4: returnbig
Flowchart:
Q3) Draw flowchart & write algorithm to print the discount applicable to the given order quantity.
Vishnu Limited calculates discounts allowed to customers on the following basis
Orderquantity Normal
discount
1-99 5%
100-199 7%
200-499 9%
500 andabove 10%
FlowChart:
To get to knowaboutmemoryallocationtovariables,Considerthe below example.
Q) Write an algorithmtofindsumof twonumbersusingfunctions.
Solution:
1. Identifythe inputstobe giventoSum() method
2. Identifythe outputtobe printedonmonitor
1. Executionof C program startsfrom main()
2. main() callssum() andgives3,4 valuestosum()
3. sum() methodcomputessumof 3 and 4 and returnsto main().
4. main() will printthe outputtothe monitor
Relational Operators in C

More Related Content

What's hot

Three address code generation
Three address code generationThree address code generation
Three address code generationRabin BK
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesHema Kashyap
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
Thesis power theft detection ch 3
Thesis power theft detection ch 3Thesis power theft detection ch 3
Thesis power theft detection ch 3Faraz Ahmed
 
Computer architecture
Computer architectureComputer architecture
Computer architectureSanjeev Patel
 
engineeringmathematics-iv_unit-ii
engineeringmathematics-iv_unit-iiengineeringmathematics-iv_unit-ii
engineeringmathematics-iv_unit-iiKundan Kumar
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.pptRavikumarR77
 
Data Algorithms And Analysis
Data Algorithms And AnalysisData Algorithms And Analysis
Data Algorithms And Analysisgarishma bhatia
 
DHT11 with Arduino
DHT11 with ArduinoDHT11 with Arduino
DHT11 with Arduinoyeokm1
 
DSP_2018_FOEHU - Lec 07 - IIR Filter Design
DSP_2018_FOEHU - Lec 07 - IIR Filter DesignDSP_2018_FOEHU - Lec 07 - IIR Filter Design
DSP_2018_FOEHU - Lec 07 - IIR Filter DesignAmr E. Mohamed
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with OutputMustafa Saeed
 
Signals and systems-1
Signals and systems-1Signals and systems-1
Signals and systems-1sarun soman
 
Orthogonal Range Searching
Orthogonal Range SearchingOrthogonal Range Searching
Orthogonal Range SearchingBenjamin Sach
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1Rajendran
 

What's hot (20)

Three address code generation
Three address code generationThree address code generation
Three address code generation
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Numerical Integration
Numerical IntegrationNumerical Integration
Numerical Integration
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
Thesis power theft detection ch 3
Thesis power theft detection ch 3Thesis power theft detection ch 3
Thesis power theft detection ch 3
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
engineeringmathematics-iv_unit-ii
engineeringmathematics-iv_unit-iiengineeringmathematics-iv_unit-ii
engineeringmathematics-iv_unit-ii
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
Data Algorithms And Analysis
Data Algorithms And AnalysisData Algorithms And Analysis
Data Algorithms And Analysis
 
DHT11 with Arduino
DHT11 with ArduinoDHT11 with Arduino
DHT11 with Arduino
 
Ripple Carry Adder
Ripple Carry AdderRipple Carry Adder
Ripple Carry Adder
 
DSP_2018_FOEHU - Lec 07 - IIR Filter Design
DSP_2018_FOEHU - Lec 07 - IIR Filter DesignDSP_2018_FOEHU - Lec 07 - IIR Filter Design
DSP_2018_FOEHU - Lec 07 - IIR Filter Design
 
Special functions
Special functionsSpecial functions
Special functions
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with Output
 
Signals and systems-1
Signals and systems-1Signals and systems-1
Signals and systems-1
 
Orthogonal Range Searching
Orthogonal Range SearchingOrthogonal Range Searching
Orthogonal Range Searching
 
K - Map
  K - Map    K - Map
K - Map
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
DFT and IDFT Matlab Code
DFT and IDFT Matlab CodeDFT and IDFT Matlab Code
DFT and IDFT Matlab Code
 

Similar to Relational Operators in C

Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C LanguageAryan Ajmer
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c languageJohn Bruslin
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSKate Campbell
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsSheba41
 
Fatima Aliasgher Portfolio
Fatima Aliasgher PortfolioFatima Aliasgher Portfolio
Fatima Aliasgher PortfolioRaheelMuhammad7
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
C chap02
C chap02C chap02
C chap02Kamran
 
Psuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxPsuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxMattFlordeliza1
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps workingSaurabh846965
 
CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsCP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsSheba41
 

Similar to Relational Operators in C (20)

09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c language
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Fatima Aliasgher Portfolio
Fatima Aliasgher PortfolioFatima Aliasgher Portfolio
Fatima Aliasgher Portfolio
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
C chap02
C chap02C chap02
C chap02
 
C chap02
C chap02C chap02
C chap02
 
Psuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxPsuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptx
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
 
CP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithmsCP4151 Advanced data structures and algorithms
CP4151 Advanced data structures and algorithms
 

More from Lakshmi Sarvani Videla (20)

Data Science Using Python
Data Science Using PythonData Science Using Python
Data Science Using Python
 
Programs on multithreading
Programs on multithreadingPrograms on multithreading
Programs on multithreading
 
Menu Driven programs in Java
Menu Driven programs in JavaMenu Driven programs in Java
Menu Driven programs in Java
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
Simple questions on structures concept
Simple questions on structures conceptSimple questions on structures concept
Simple questions on structures concept
 
Errors incompetitiveprogramming
Errors incompetitiveprogrammingErrors incompetitiveprogramming
Errors incompetitiveprogramming
 
Recursive functions in C
Recursive functions in CRecursive functions in C
Recursive functions in C
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
 
Functions
FunctionsFunctions
Functions
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Singlelinked list
Singlelinked listSinglelinked list
Singlelinked list
 
Graphs
GraphsGraphs
Graphs
 
B trees
B treesB trees
B trees
 
Functions in python3
Functions in python3Functions in python3
Functions in python3
 
Dictionary
DictionaryDictionary
Dictionary
 
Sets
SetsSets
Sets
 
Lists
ListsLists
Lists
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C programs
C programsC programs
C programs
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

Relational Operators in C

  • 1. SESSION NUMBER: 02 Session Outcome: At the end of this session on ALGORITHMS AND FLOWCHARTS, Students will be able: 1. To design algorithms for conditional problems. 2. To design flowcharts for iterativeproblems. Ex 1. Write an algorithmanddraw flowchart to findwhetherpersoniseligibleforvote ornot(above 18 eligible). Solution: 1. Identifythe inputstobe giventovoteEligibilityfunction ( here itisage ) 2. Identifythe outputtobe printedonmonitor (here itis Eligible ornotEligible) Algorithmfor main() function: Step1: Start Step2: age:=20 Step3: Call voteEligibility(age) function Step4: Stop Algorithmfor voteEligibility(intage) function: Step1: Start Step2: if( age >= 18) then print“Eligible to Vote” Step3: else print“Not eligible toVote” Step4: returnto main()
  • 2. Flowchart: Code: #include<stdio.h> // headerfile voidVoteEligibility(int); // functionprototype intmain() { intage; age = 20; voteEligibility(age); // functioncall return0; } voidvoteEligibility(intage) //functionbodybeginshere { if(age>=18) { printf("Eligibletovote"); } else { printf("NotEligible tovote"); } return; } Here in the above program,we have to write #include<stdio.h> stdioisthe short formfor standardinputand output stdio.hisan headerfile. A headerfile containsmanyfunctions. Some of the available functionsinheaderfilestdio.hare printf,scanf,etc. // are comments. Commentswill enable youtounderstandthe code.Whateveryouwrite after//are not
  • 3. executedbythe compiler. intmain() Executionof Cprogram starts frommain() andit isan inbuiltmethod voidVoteEligibility(int); Functionprototype indicatesthe returntype of function, functionname,inputparameters and theirdatatypes intage; a memoryisallocatedandname giventomemorylocationisage. Here age iscalleda variable.A namedmemorylocationiscalledavariable intis a data type indicatingthatwe can store integervaluesinage memorylocation. The range of valuesthatcan be storedinan integervariable,age is -32767 to 32768 in a 32- bitcomputer age=20; will putvalue 20 inthe age memorylocation. voteEligibility(age); main() callsthe function voteEligibility(age); main() pausesexecution CPU starts executingVoteEligibility(age);function voidvoteEligibility(intage) { The userdefinedfunctionvoteEligibility(intage) isgivenfunctionalityhere.Itiscalleduser definedfunctionas thisfunctioniswrittenbyprogrammer.Butprintf()functioniscalled inbuiltfunctionasthe code forprintf() iswrittenbysome one else andwe are usingit. { indicate the functionbeginshere,inotherwords,the functionblockbeginsher if(age>=18) { If is an conditional statementasitchecksa conditionage >= 18. if the conditionistrue then{ indicatesbeginningof if block.all the statementsinside{ and} of if blockwill be executed Alsohere age referstothe valuespresentinage memorylocation. If is a keywordasit has some special meaning printf("Eligibletovote"); } printf will printthe message “Eligible tovote”onthe monitor. } indicatesendof if block printf isan inbuiltfunctioninstdio.h else { else mustbe writtenafterthe if blockandwill be executedif the conditionage>=18 becomesfalse.i.e,the value insideage memorylocationisnotgreaterthan18 thenelse blockwill execute else isalsoa keyword
  • 4. printf("Eligibletovote"); } All the statementsinside else blockwill be executedif the conditionage>=18 isfalse return will enable youtocome outof the voteEligibilityfunctionandreturntothe main() where thisfunctionwascalled } End of voteEligibility functionblock return0; main() functionreturns0to compilerindicatingthe programexecutedsuccessfully } End of main() function
  • 5. Example 2: Use an algorithmtoprintall natural numbersfrom1 to N to make the studentsunderstanddesignof algorithmsandflowchartfor iterative problems. Solution: 1. Identifythe inputstobe giventoPrintmethod( here itis n) 2. Identifythe outputtobe printedonmonitor(all natural numbersfrom1 to n) Algorithmfor main() function: Step1: Start Step2: n:=20 Step3: Call Print(n) function Step4: Stop Algorithmfor Print(n) function: Step1: Start Step2: i := 1 Step3: if ( i <= n) then Step3.1 : printi Step3.2: i := i+1 Step3.3: go to step3 Step4: returnto main() Flowchart: main() print(intn) Here the main() methodpausesandthe CPU control goesto print(intn) Here the CPU control goesback to main() Start n := 20 Print(n) Stop Print(intn) i <= n print i i := 1 i := i+1 True False
  • 7. Practice SessionProblems: Q1) Write an algorithmanddraw flowchart tofind biggestof giventwonumber. Algorithmfor main() function: Step1: Start Step2: n1:=10 Step3: n2 := 20 Step4: biggest_number:=calculateBig(n1,n2) Step5: printbiggest_number Step6: Stop Algorithmfor calculateBig(intn1, int n2) function: Step1: Start Step2: if( n1 >= n2) then big:= n1 Step3: else big:= n2 Step4: returnbig FlowChart:
  • 8. Q2) Write an algorithmanddraw flowchart tofindthe biggestof given3 distinctnumbers. Algorithmfor main() function: Step1: Start Step2 : n1 := 10 Step3 : n2 := 20 Step4 : n3 := 30 Step5: ans=calculateBig(n1,n2,n3) Step6: printans Step7: Stop Algorithmfor calculateBig(intn1, int n2, int n3) function: Step1: Start Step2 : if n1 > n2 then Step2.1: if n1 > n3 then big:= n1 Step2.2: else big:= n3 Step3: else Step3.1 if n2 > n3 then big:= n2 Step3.2 else big:= n3 Step4: returnbig Flowchart:
  • 9. Q3) Draw flowchart & write algorithm to print the discount applicable to the given order quantity. Vishnu Limited calculates discounts allowed to customers on the following basis Orderquantity Normal discount 1-99 5% 100-199 7% 200-499 9% 500 andabove 10% FlowChart:
  • 10. To get to knowaboutmemoryallocationtovariables,Considerthe below example. Q) Write an algorithmtofindsumof twonumbersusingfunctions. Solution: 1. Identifythe inputstobe giventoSum() method 2. Identifythe outputtobe printedonmonitor 1. Executionof C program startsfrom main() 2. main() callssum() andgives3,4 valuestosum() 3. sum() methodcomputessumof 3 and 4 and returnsto main(). 4. main() will printthe outputtothe monitor