SlideShare a Scribd company logo
1 of 4
Q1
Write a program to find GreatNum from a series of numbers
1.Contract: GreatNum number,numbers ........>number
2.Header: GreatNum(nOfvalues(sequenceOf numbers))...
3.Example GreatNum(3,(23 45 56))-------> 56
4. ALGORITHM
STEP1.Start
STEP2.Declare 'nOfvalues' to get the no of sequence of numbers.Declare Maxval=0
STEP3.Read the sequence of numbers and store the numbers.
STEP4.Check sequence, If a number > Maxval ,then save Maxval as that number
STEP5.Check next number in sequence ,if number >Maxval,then save Maxval as that number
STEP6.Repeat steps 4 to 5 until last of sequence.
STEP7.Display Maxval.
STEP8.Stop.
Sl.NoInputOutput13, 23 45 565624, 10 45 67 3267
Q2.
Sum of squares and square of sums of 2 nos and find diff
1.Contract:calcDiffnce number,number------>number
2.Header: calcDiffnce(nuM1,nuM2)....
3.Example calcDiffnce (4,5)----->40
4.ALGORITHM
STEP1.Start.
STEP2.Declare variables nuM1 and nuM2 and read and store the values.
STEP3.Declare SumoFsqr ,SqroFsum and Diff and initialise to 0.
STEP4. SumoFsqr = (nuM1*nuM1)+(nuM2*nuM2)
STEP5.SqroFsum =(nuM1+nuM2)* (nuM1+nuM2)
STEP6.Diff= SqroFsum - SumoFsqr
STEP7.Display Diff
Sl.NoInputOutput14,540210,12240
Q3
Write a program TheaterProfit(noFattendees) to calculate the calcSales,calcCost and NetProfit
1.Contract: TheaterProfit numbers----->numbers
2.Header:TheaterProfit(noFattendees))...
3.Example TheaterProfit(200)------->880
4.ALGORITHM
STEP1:Start
STEP2. Declare variable 'nOfattendees' and initialise to 0 to save no of attending people show.
STEP3.Input the value for nOfattendees and save.Declare and initialise Ticktprice= 50,SetCost=20,AtndCost=0.5.
STEP4.Declare variables 'calcSales' for calculating cost of ticket sales and 'calcCost' for calculating cost of show.
STEP5.calcSales=nOfattendees * Ticktprice
STEP6.calcCost=SetCost+ nOfattendees* AtndCost
STEP7..Calculate the NetProfit= calcSales- calcCost and display NetProfit.
STEP8 Stop.
Sl.NoInputOutput1104752251217.5
Q4.area and volume of cylinder,given base radius and height
1.Contract: calcAreaVolcyl number,number----->number,number
2.Header: calcAreaVolcyl (baseradius,height)
3.Example calcAreaVolcyl(12,13.5)------>( 1921.68,6104.16)
4.ALGORITHM
STEP1:Start
STEP2:DEFINE PI as 3.14
STEP3:Declare variables baseradius and height of the cylinder and read the values.
STEP3:Declare cylSArea and cylVolume and initialise 0.
STEP4:cylSArea=(2*PI* baseradius* height)+(2*PI* baseradius*baseradius)
STEP5: cylSArea=( PI*baseradius*baseradius*height)
STEP6:Display cylSArea and cylVolume
STEP7:Stop
Sl.NoInputsOutputs16,5414.48,565.224,10351.68,502.4
Q5.To count no of words in a string
1. Contract countWords string.-------->number
2.Header :countWords(strng,countVal)....
3.Example countWords( 滴 ave a nice day----->12
4.ALGORITHM
STEP1:Start
STEP2:Declare a string variable as array of characters strng[] and read from user and store string .
STEP3:Declare and Initialise countVal=0.
STEP4:Read string.Check each character strng[i], IF character equals ' ' and next character is not ' ' ,THEN increment
countVal.
STEP5:If character equals 'null' then increment countVal .
STEP6:Repeat step3 to 4 ,until encounter 'null' character.
STEP7:Display countVal
STEP8:Stop
Sl.NoInputOutput1Have a nice Day42I like chocolates and cream5
Q6.Convert decimal to binary value
1.Contract DecToBin number ----->number8)
2.Header DecToBin(decno)....
3.Example DecToBin(25)----->11001
4.ALGORITHM
STEP1:Start
STEP2:Declare variable decno and read decno from user.
STEP3:Declare variables quotnt and rem and initialise as 0.Declare and initialise a variable count as 0.
STEP4:quotnt equals to decno/2 and rem equals to decno%2
STEP5:rem is 0 or 1.Store rem as first element of an array arrno[].increment count .save new decno =quotnt.
STEP6:Repeat steps 4 and 5 until decno reduces to 0.Store rem as next element of array.
STEP7:Print the arrno[] backwards from arrno[count-1] ,as the Binary value.
STEP8:Stop
SL.NoInputsOutputs125110012121100
Q7 Factorial of a number using recursive function.
1.Contract FACT number---->number
2.Header FACT(number)
3.Example FACT(8)-------->40320
4.ALGORITHM
STEP1:Start
STEP2:Declare variables num ,fact and i.Initialise fact=1 and i=1
STEP3:Read the required number from user and store as num.
STEP4:Update fact as fact*i.
STEP4:Increment i
STEP5:Repeat steps 4 and 5 until i less than or equals num
STEP6:Display fact
STEP7:Stop
Sl.No InputOutput184032025120
Q8 Print Reverse an integer array without using another array
1.Contract RevArray(number,numbers)-------->numbers
2.Header RevArray(number,numbers)
3.Example RevArray( 7,2 34 67 8 98 31 56)-------->(56 31 98 8 67 34 2)
4.ALGORITHM
STEP1:Declare array arr[]and no of elements LEN.
STEP2:Input no of elements from user and read and store arr[LEN]
STEP3:Initialise i=0.Initialise temp as 0
STEP4:Put temp=arr[i].Then put arr[i] =arr[LEN-i]
STEP5:Put arr[LEN-i]=temp.Increment i
STEP6:Repeat steps 4 and 5 until i is less than or equals LEN/2
STEP7:Display arr[i]
STEP8:Stop
Sl.NoInputOutput15, 12 56 7 0 4545 0 7 56 1228,1 43 88 76 44 3 32 99 32 3 44 76 88 43 1
Q9.To concatinate two strings string1 and string2.
1. Contract : ConcatStr(string, string)--------->string
2.Header ConcatStr(string,string)
3.Example ConcatStr(Housing,Plot)---------->HousingPlot
4.ALGORITHM
STEP1:Declare str1 and str2 as two string arrays
STEP2:Read str1 and str2 from the user and store.
STEP3:Print str1[i] increment I
STEP4:Repeat 3 while str[i] is not equal to 'null '.
STEP5:When str1[i] is 'null' do step 5
STEP5:Print str2[i] .Increment i
STEP6:Repeat 5 until str2[i] equals 'null'.
STEP7:Stop
algorithmdivs

More Related Content

What's hot

computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
ecomputernotes
 
HOW TO < 今日
HOW TO < 今日HOW TO < 今日
HOW TO < 今日
kawarasho
 

What's hot (20)

Data Structure and Algorithms Queues
Data Structure and Algorithms QueuesData Structure and Algorithms Queues
Data Structure and Algorithms Queues
 
Sheet 2
Sheet 2Sheet 2
Sheet 2
 
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
Samples solution-manual-assembly-language-for-x86-processors-7th-edition-by-k...
 
Inc decsourcefile
Inc decsourcefileInc decsourcefile
Inc decsourcefile
 
Fibonacci series c++
Fibonacci series c++Fibonacci series c++
Fibonacci series c++
 
Fibonacci Series Program in C++
Fibonacci Series Program in C++Fibonacci Series Program in C++
Fibonacci Series Program in C++
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
 
4.5 sec and csc worked 3rd
4.5   sec and csc worked 3rd4.5   sec and csc worked 3rd
4.5 sec and csc worked 3rd
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
 
Breadth-First-Search algorithm with Code
Breadth-First-Search algorithm with CodeBreadth-First-Search algorithm with Code
Breadth-First-Search algorithm with Code
 
Perlで任意精度計算
Perlで任意精度計算Perlで任意精度計算
Perlで任意精度計算
 
Lab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicLab 2-Simple Combinational Logic
Lab 2-Simple Combinational Logic
 
Lab 3 Multi-Function Gate
Lab 3   Multi-Function GateLab 3   Multi-Function Gate
Lab 3 Multi-Function Gate
 
HOW TO < 今日
HOW TO < 今日HOW TO < 今日
HOW TO < 今日
 
New text document
New text documentNew text document
New text document
 
timingExercise
timingExercisetimingExercise
timingExercise
 
Introduction to java Programming, Addition, Substraction, Multiplication, Div...
Introduction to java Programming, Addition, Substraction, Multiplication, Div...Introduction to java Programming, Addition, Substraction, Multiplication, Div...
Introduction to java Programming, Addition, Substraction, Multiplication, Div...
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Temp conversion
Temp conversionTemp conversion
Temp conversion
 
Programming meeting #8
Programming meeting #8Programming meeting #8
Programming meeting #8
 

Viewers also liked

NaSPA_2016+JULY-AUG-sm
NaSPA_2016+JULY-AUG-smNaSPA_2016+JULY-AUG-sm
NaSPA_2016+JULY-AUG-sm
Sharon Wrobel
 
Java Script Ist Anders
Java Script Ist AndersJava Script Ist Anders
Java Script Ist Anders
jlink
 

Viewers also liked (15)

Landeros Resume-1
Landeros Resume-1Landeros Resume-1
Landeros Resume-1
 
Dollies Industriais
Dollies IndustriaisDollies Industriais
Dollies Industriais
 
Julio 2016
Julio 2016Julio 2016
Julio 2016
 
Analisis de hc
Analisis de hcAnalisis de hc
Analisis de hc
 
NaSPA_2016+JULY-AUG-sm
NaSPA_2016+JULY-AUG-smNaSPA_2016+JULY-AUG-sm
NaSPA_2016+JULY-AUG-sm
 
Research supportslideskcl
Research supportslideskclResearch supportslideskcl
Research supportslideskcl
 
Great wall of china ppt
Great wall of china pptGreat wall of china ppt
Great wall of china ppt
 
Business Economics- An Introduction
Business Economics- An IntroductionBusiness Economics- An Introduction
Business Economics- An Introduction
 
Java Script Ist Anders
Java Script Ist AndersJava Script Ist Anders
Java Script Ist Anders
 
Photo composition basic
Photo composition basicPhoto composition basic
Photo composition basic
 
How to DIY lo-fi UX testing with customers
How to DIY lo-fi UX testing with customersHow to DIY lo-fi UX testing with customers
How to DIY lo-fi UX testing with customers
 
Dissertation
DissertationDissertation
Dissertation
 
User Happyをささえるアジャイルのココロとスクラムのキホン
User HappyをささえるアジャイルのココロとスクラムのキホンUser Happyをささえるアジャイルのココロとスクラムのキホン
User Happyをささえるアジャイルのココロとスクラムのキホン
 
COMPETENCIAS LABORALES DE UN GUIA
COMPETENCIAS LABORALES DE UN GUIACOMPETENCIAS LABORALES DE UN GUIA
COMPETENCIAS LABORALES DE UN GUIA
 
Afiliació i atur febrer 2016
Afiliació i atur febrer 2016Afiliació i atur febrer 2016
Afiliació i atur febrer 2016
 

Similar to algorithmdivs

2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
AAKASH KUMAR
 

Similar to algorithmdivs (20)

Arrry structure Stacks in data structure
Arrry structure Stacks  in data structureArrry structure Stacks  in data structure
Arrry structure Stacks in data structure
 
algorithm
algorithmalgorithm
algorithm
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
The Ring programming language version 1.5.2 book - Part 74 of 181
The Ring programming language version 1.5.2 book - Part 74 of 181The Ring programming language version 1.5.2 book - Part 74 of 181
The Ring programming language version 1.5.2 book - Part 74 of 181
 
The Ring programming language version 1.5.4 book - Part 77 of 185
The Ring programming language version 1.5.4 book - Part 77 of 185The Ring programming language version 1.5.4 book - Part 77 of 185
The Ring programming language version 1.5.4 book - Part 77 of 185
 
C Arrays.ppt
C Arrays.pptC Arrays.ppt
C Arrays.ppt
 
The Ring programming language version 1.5.1 book - Part 73 of 180
The Ring programming language version 1.5.1 book - Part 73 of 180The Ring programming language version 1.5.1 book - Part 73 of 180
The Ring programming language version 1.5.1 book - Part 73 of 180
 
The Ring programming language version 1.9 book - Part 88 of 210
The Ring programming language version 1.9 book - Part 88 of 210The Ring programming language version 1.9 book - Part 88 of 210
The Ring programming language version 1.9 book - Part 88 of 210
 
Lec2&3 data structure
Lec2&3 data structureLec2&3 data structure
Lec2&3 data structure
 
Lec2
Lec2Lec2
Lec2
 
Lecture 9_Classes.pptx
Lecture 9_Classes.pptxLecture 9_Classes.pptx
Lecture 9_Classes.pptx
 
The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88The Ring programming language version 1.3 book - Part 59 of 88
The Ring programming language version 1.3 book - Part 59 of 88
 
The Ring programming language version 1.2 book - Part 56 of 84
The Ring programming language version 1.2 book - Part 56 of 84The Ring programming language version 1.2 book - Part 56 of 84
The Ring programming language version 1.2 book - Part 56 of 84
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
histgram[1].ppt
histgram[1].ppthistgram[1].ppt
histgram[1].ppt
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
 
The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30The Ring programming language version 1.4 book - Part 21 of 30
The Ring programming language version 1.4 book - Part 21 of 30
 
The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88The Ring programming language version 1.3 book - Part 85 of 88
The Ring programming language version 1.3 book - Part 85 of 88
 

algorithmdivs

  • 1. Q1 Write a program to find GreatNum from a series of numbers 1.Contract: GreatNum number,numbers ........>number 2.Header: GreatNum(nOfvalues(sequenceOf numbers))... 3.Example GreatNum(3,(23 45 56))-------> 56 4. ALGORITHM STEP1.Start STEP2.Declare 'nOfvalues' to get the no of sequence of numbers.Declare Maxval=0 STEP3.Read the sequence of numbers and store the numbers. STEP4.Check sequence, If a number > Maxval ,then save Maxval as that number STEP5.Check next number in sequence ,if number >Maxval,then save Maxval as that number STEP6.Repeat steps 4 to 5 until last of sequence. STEP7.Display Maxval. STEP8.Stop. Sl.NoInputOutput13, 23 45 565624, 10 45 67 3267 Q2. Sum of squares and square of sums of 2 nos and find diff 1.Contract:calcDiffnce number,number------>number 2.Header: calcDiffnce(nuM1,nuM2).... 3.Example calcDiffnce (4,5)----->40 4.ALGORITHM STEP1.Start. STEP2.Declare variables nuM1 and nuM2 and read and store the values. STEP3.Declare SumoFsqr ,SqroFsum and Diff and initialise to 0. STEP4. SumoFsqr = (nuM1*nuM1)+(nuM2*nuM2) STEP5.SqroFsum =(nuM1+nuM2)* (nuM1+nuM2) STEP6.Diff= SqroFsum - SumoFsqr STEP7.Display Diff Sl.NoInputOutput14,540210,12240 Q3 Write a program TheaterProfit(noFattendees) to calculate the calcSales,calcCost and NetProfit 1.Contract: TheaterProfit numbers----->numbers 2.Header:TheaterProfit(noFattendees))... 3.Example TheaterProfit(200)------->880 4.ALGORITHM STEP1:Start STEP2. Declare variable 'nOfattendees' and initialise to 0 to save no of attending people show. STEP3.Input the value for nOfattendees and save.Declare and initialise Ticktprice= 50,SetCost=20,AtndCost=0.5. STEP4.Declare variables 'calcSales' for calculating cost of ticket sales and 'calcCost' for calculating cost of show. STEP5.calcSales=nOfattendees * Ticktprice
  • 2. STEP6.calcCost=SetCost+ nOfattendees* AtndCost STEP7..Calculate the NetProfit= calcSales- calcCost and display NetProfit. STEP8 Stop. Sl.NoInputOutput1104752251217.5 Q4.area and volume of cylinder,given base radius and height 1.Contract: calcAreaVolcyl number,number----->number,number 2.Header: calcAreaVolcyl (baseradius,height) 3.Example calcAreaVolcyl(12,13.5)------>( 1921.68,6104.16) 4.ALGORITHM STEP1:Start STEP2:DEFINE PI as 3.14 STEP3:Declare variables baseradius and height of the cylinder and read the values. STEP3:Declare cylSArea and cylVolume and initialise 0. STEP4:cylSArea=(2*PI* baseradius* height)+(2*PI* baseradius*baseradius) STEP5: cylSArea=( PI*baseradius*baseradius*height) STEP6:Display cylSArea and cylVolume STEP7:Stop Sl.NoInputsOutputs16,5414.48,565.224,10351.68,502.4 Q5.To count no of words in a string 1. Contract countWords string.-------->number 2.Header :countWords(strng,countVal).... 3.Example countWords( 滴 ave a nice day----->12 4.ALGORITHM STEP1:Start STEP2:Declare a string variable as array of characters strng[] and read from user and store string . STEP3:Declare and Initialise countVal=0. STEP4:Read string.Check each character strng[i], IF character equals ' ' and next character is not ' ' ,THEN increment countVal. STEP5:If character equals 'null' then increment countVal . STEP6:Repeat step3 to 4 ,until encounter 'null' character. STEP7:Display countVal STEP8:Stop Sl.NoInputOutput1Have a nice Day42I like chocolates and cream5 Q6.Convert decimal to binary value 1.Contract DecToBin number ----->number8) 2.Header DecToBin(decno).... 3.Example DecToBin(25)----->11001 4.ALGORITHM STEP1:Start STEP2:Declare variable decno and read decno from user. STEP3:Declare variables quotnt and rem and initialise as 0.Declare and initialise a variable count as 0. STEP4:quotnt equals to decno/2 and rem equals to decno%2 STEP5:rem is 0 or 1.Store rem as first element of an array arrno[].increment count .save new decno =quotnt. STEP6:Repeat steps 4 and 5 until decno reduces to 0.Store rem as next element of array. STEP7:Print the arrno[] backwards from arrno[count-1] ,as the Binary value.
  • 3. STEP8:Stop SL.NoInputsOutputs125110012121100 Q7 Factorial of a number using recursive function. 1.Contract FACT number---->number 2.Header FACT(number) 3.Example FACT(8)-------->40320 4.ALGORITHM STEP1:Start STEP2:Declare variables num ,fact and i.Initialise fact=1 and i=1 STEP3:Read the required number from user and store as num. STEP4:Update fact as fact*i. STEP4:Increment i STEP5:Repeat steps 4 and 5 until i less than or equals num STEP6:Display fact STEP7:Stop Sl.No InputOutput184032025120 Q8 Print Reverse an integer array without using another array 1.Contract RevArray(number,numbers)-------->numbers 2.Header RevArray(number,numbers) 3.Example RevArray( 7,2 34 67 8 98 31 56)-------->(56 31 98 8 67 34 2) 4.ALGORITHM STEP1:Declare array arr[]and no of elements LEN. STEP2:Input no of elements from user and read and store arr[LEN] STEP3:Initialise i=0.Initialise temp as 0 STEP4:Put temp=arr[i].Then put arr[i] =arr[LEN-i] STEP5:Put arr[LEN-i]=temp.Increment i STEP6:Repeat steps 4 and 5 until i is less than or equals LEN/2 STEP7:Display arr[i] STEP8:Stop Sl.NoInputOutput15, 12 56 7 0 4545 0 7 56 1228,1 43 88 76 44 3 32 99 32 3 44 76 88 43 1 Q9.To concatinate two strings string1 and string2. 1. Contract : ConcatStr(string, string)--------->string 2.Header ConcatStr(string,string) 3.Example ConcatStr(Housing,Plot)---------->HousingPlot 4.ALGORITHM STEP1:Declare str1 and str2 as two string arrays STEP2:Read str1 and str2 from the user and store. STEP3:Print str1[i] increment I STEP4:Repeat 3 while str[i] is not equal to 'null '. STEP5:When str1[i] is 'null' do step 5 STEP5:Print str2[i] .Increment i STEP6:Repeat 5 until str2[i] equals 'null'. STEP7:Stop