SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Robotics in AI
Robotics in AIRobotics in AI
Robotics in AIAkhil TR
 
Detection and recognition of face using neural network
Detection and recognition of face using neural networkDetection and recognition of face using neural network
Detection and recognition of face using neural networkSmriti Tikoo
 
Particle Swarm Optimization
Particle Swarm OptimizationParticle Swarm Optimization
Particle Swarm OptimizationStelios Petrakis
 
Pattern recognition facial recognition
Pattern recognition facial recognitionPattern recognition facial recognition
Pattern recognition facial recognitionMazin Alwaaly
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project reportSarang Afle
 
Face mask detection
Face mask detection Face mask detection
Face mask detection Sonesh yadav
 
Real-time Face Recognition & Detection Systems 1
Real-time Face Recognition & Detection Systems 1Real-time Face Recognition & Detection Systems 1
Real-time Face Recognition & Detection Systems 1Suvadip Shome
 
SPEECH RECOGNITION USING NEURAL NETWORK
SPEECH RECOGNITION USING NEURAL NETWORK SPEECH RECOGNITION USING NEURAL NETWORK
SPEECH RECOGNITION USING NEURAL NETWORK Kamonasish Hore
 
Chapter 2 robot kinematics
Chapter 2   robot kinematicsChapter 2   robot kinematics
Chapter 2 robot kinematicsnguyendattdh
 
Face Recognition Home Security System(Slide)
Face Recognition Home Security System(Slide)Face Recognition Home Security System(Slide)
Face Recognition Home Security System(Slide)Suman Mia
 
Lecture 1 ME 176 1 Introduction
Lecture 1 ME 176 1 IntroductionLecture 1 ME 176 1 Introduction
Lecture 1 ME 176 1 IntroductionLeonides De Ocampo
 
Case study on smart card (embeded system) based on IOT
Case study on smart card (embeded system) based on IOTCase study on smart card (embeded system) based on IOT
Case study on smart card (embeded system) based on IOTdivyawani2
 
Draw in Air | Open CV Project
Draw in Air | Open CV ProjectDraw in Air | Open CV Project
Draw in Air | Open CV ProjectAviral Chaurasia
 

Tendances (20)

Robotics in AI
Robotics in AIRobotics in AI
Robotics in AI
 
Bee algorithm
Bee algorithmBee algorithm
Bee algorithm
 
Detection and recognition of face using neural network
Detection and recognition of face using neural networkDetection and recognition of face using neural network
Detection and recognition of face using neural network
 
Particle Swarm Optimization
Particle Swarm OptimizationParticle Swarm Optimization
Particle Swarm Optimization
 
MPC
MPCMPC
MPC
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Pattern recognition facial recognition
Pattern recognition facial recognitionPattern recognition facial recognition
Pattern recognition facial recognition
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project report
 
Unit converter using in c
Unit converter using in cUnit converter using in c
Unit converter using in c
 
Face mask detection
Face mask detection Face mask detection
Face mask detection
 
Real-time Face Recognition & Detection Systems 1
Real-time Face Recognition & Detection Systems 1Real-time Face Recognition & Detection Systems 1
Real-time Face Recognition & Detection Systems 1
 
SPEECH RECOGNITION USING NEURAL NETWORK
SPEECH RECOGNITION USING NEURAL NETWORK SPEECH RECOGNITION USING NEURAL NETWORK
SPEECH RECOGNITION USING NEURAL NETWORK
 
Chapter 2 robot kinematics
Chapter 2   robot kinematicsChapter 2   robot kinematics
Chapter 2 robot kinematics
 
Face recognization technology
Face recognization technologyFace recognization technology
Face recognization technology
 
Face Recognition Home Security System(Slide)
Face Recognition Home Security System(Slide)Face Recognition Home Security System(Slide)
Face Recognition Home Security System(Slide)
 
INTELLIGENT WATER DROPLET
INTELLIGENT WATER DROPLETINTELLIGENT WATER DROPLET
INTELLIGENT WATER DROPLET
 
Lecture 1 ME 176 1 Introduction
Lecture 1 ME 176 1 IntroductionLecture 1 ME 176 1 Introduction
Lecture 1 ME 176 1 Introduction
 
Case study on smart card (embeded system) based on IOT
Case study on smart card (embeded system) based on IOTCase study on smart card (embeded system) based on IOT
Case study on smart card (embeded system) based on IOT
 
Draw in Air | Open CV Project
Draw in Air | Open CV ProjectDraw in Air | Open CV Project
Draw in Air | Open CV Project
 
07 robot arm kinematics
07 robot arm kinematics07 robot arm kinematics
07 robot arm kinematics
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Dernier

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Dernier (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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