SlideShare a Scribd company logo
1 of 80
Download to read offline
Team Emertxe
Basic Refresher
Assignment 5
Assignment 5
Assignment 5
WAP to generate AP, GP, HP series.
Assignment 5
WAP to generate AP, GP, HP series.
Input:
Assignment 5
WAP to generate AP, GP, HP series.
Input: Read integer ‘A’, ‘R’ and ‘N’.
Assignment 5
WAP to generate AP, GP, HP series.
Input: Read integer ‘A’, ‘R’ and ‘N’.
where:
A = First number
R = Common difference(AP & HP), Common ratio(GP)
N = number of terms
Assignment 5
WAP to generate AP, GP, HP series.
Input: Read integer ‘A’, ‘R’ and ‘N’.
where:
A = First number
R = Common difference(AP & HP), Common ratio(GP)
N = number of terms
Output:
Assignment 5
WAP to generate AP, GP, HP series.
Input: Read integer ‘A’, ‘R’ and ‘N’.
where:
A = First number
R = Common difference(AP & HP), Common ratio(GP)
N = number of terms
Output: Print AP , GP and HP series.
Assignment 5
What is AP series?
Assignment 5
What is AP series?
A sequence of numbers in which the common difference between
two consecutive terms is constant.
Assignment 5
How to generate AP series?
Assignment 5
How to generate AP series?
Example :-
A = 3, R = 3 , N = 3
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Sum of previous term and common difference(R) -> next term
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Sum of previous term and common difference(R) -> next term
The series : 3, ?
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Sum of previous term and common difference(R) -> next term
The series : 3, ?
What is the next term?
3 ?
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Sum of previous term and common difference(R) -> next term
The series : 3, ?
What is the next term?
3 6
3 + 3 = 6
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Sum of previous term and common difference(R) -> next term
The series : 3, 6, ?
What is the next term?
3 9
6
6 + 3 = 9
Assignment 5
How to generate AP series?
First term ‘A’ = 3, Common difference ‘R’ = 3 and ‘N’ = 3
The series : 3, 6, 9
Assignment 5
What is GP series?
Assignment 5
What is GP series?
A sequence of numbers in which the common ratio between two
consecutive terms is constant.
Assignment 5
How to generate GP series?
Assignment 5
How to generate GP series?
Example :-
A = 3, R = 3 , N = 3
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Product of previous term and common ratio (R) -> next term
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Product of previous term and common ratio (R) -> next term
The series : 3, ?
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Product of previous term and common ratio (R) -> next term
The series : 3, ?
What is the next term?
?
3
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Product of previous term and common ratio (R) -> next term
The series : 3, ?
What is the next term?
3 * 3 = 9
9
3
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
How to find the next term ?
Product of previous term and common ratio (R) -> next term
The series : 3, 9, ?
What is the next term?
9 * 3 = 27
27
9
3
Assignment 5
How to generate GP series?
First term ‘A’ = 3, Common ratio ‘R’ = 3 and ‘N’ = 3
The series : 3, 9, 27
Assignment 5
What is HP series?
Assignment 5
What is HP series?
A sequence of numbers whose reciprocals form an arithmetic
progression.
Assignment 5
How to generate HP series?
Assignment 5
How to generate HP series?
Example :-
A = 3, R = 3 , N = 3
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
The series : 1/3, ?
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
The series : 1/3, ?
In float : 0.333333, ?
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
The series : 1/3, ?
In float : 0.333333, ?
What is the next term?
1/3 ?
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
The series : 1/3, 1/6, ?
In float : 0.333333, 0.166667, ?
What is the next term?
1/3 1/6
1 / (3+3) = 1/6
Assignment 5
How to generate HP series?
First term is –> 1/A (A = 3) and the AP series : 3, 6, 9
How to find the next term ?
Reciprocal of next term in AP series-> next term
The series : 1/3, 1/6, ?
In float : 0.333333, 0.166667, 0.111111
What is the next term?
1/3 1/6
1 / (3+3) = 1/9
1/9
Assignment 5
For example:- A = 3, R = 3 , N = 3
Print series in float:-
Assignment 5
For example:- A = 3, R = 3 , N = 3
The HP series is :- 1/3, 1/6, 1/9
Print series in float:-
Assignment 5
For example:- A = 3, R = 3 , N = 3
The HP series is :- 1/3, 1/6, 1/9
Print the series in float values
Print series in float:-
Assignment 5
For example:- A = 3, R = 3 , N = 3
The HP series is :- 1/3, 1/6, 1/9
Print the series in float values
In float : 0.333333, 0.166667, 0.111111
Print series in float:-
Assignment 5
Can you guess the output ?
Assignment 5
 int num1 = 3 , num2 = 2;
float res = num1 / num2;
Can you guess the output ?
Assignment 5
 int num1 = 3 , num2 = 2;
float res = num1 / num2;
It will print 1.000000
Can you guess the output ?
Assignment 5
 int num1 = 3 , num2 = 2;
float res = num1 / num2;
It will print 1.000000
 int num1 = 3 , num2 = 2;
float res = (float) num1 / num2;
Can you guess the output ?
Assignment 5
 int num1 = 3 , num2 = 2;
float res = num1 / num2;
It will print 1.000000
 int num1 = 3 , num2 = 2;
float res = (float) num1 / num2;
It will print 1.500000
Can you guess the output ?
3 / 2 1.000000
=
int float
int
3.000000 / 2 1.500000
=
float float
int
Assignment 5
 int num1 = 3 , num2 = 2;
float res = num1 / num2;
It will print 1.000000
 int num1 = 3 , num2 = 2;
float res = (float) num1 / num2;
It will print 1.500000
Can you guess the output ?
Doing int / int and storing in float.
So, decimal part(.5 of 1.5) will be
truncated and only 1.000000 will
be stored in float.
Doing float / int and storing in
float.
So, decimal part(.5 of 1.5) will not
be truncated and 1.500000 will be
stored in float. This is typecasting
Assignment 5
Example’s:
Assignment 5
Example’s:
Input:
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output:
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input:
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input: A = 5 , R = 5 , N = 3
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input: A = 5 , R = 5 , N = 3
Output:
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input: A = 5 , R = 5 , N = 3
Output: AP = 5, 10, 15
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input: A = 5 , R = 5 , N = 3
Output: AP = 5, 10, 15
GP = 5, 25, 125
Assignment 5
Example’s:
Input: A = 2 , R = 3 , N = 4
Output: AP = 2, 5, 8, 11
GP = 2, 6, 18, 54
HP = 0.500000, 0.200000, 0.125000, 0.0909091
Input: A = 5 , R = 5 , N = 3
Output: AP = 5, 10, 15
GP = 5, 25, 125
HP = 0.200000,0.100000, 0.066667
Sample execution:-
Assignment 5
Sample execution:-
Assignment 5
Sample execution:-
Assignment 5
Assignment 5
Pre-requisites:-
Assignment 5
Pre-requisites:-
Loops
Assignment 5
Pre-requisites:-
Loops
Operators
Assignment 5
Pre-requisites:-
Loops
Operators
Data Types
Assignment 5
Pre-requisites:-
Loops
Operators
Data Types
Objective:-
Assignment 5
Pre-requisites:-
Loops
Operators
Data Types
Objective:-
To understand the concept of
• Continuous looping
Assignment 5
Pre-requisites:-
Loops
Operators
Data Types
Objective:-
To understand the concept of
• Continuous looping
• If-else constructs
Assignment 5
Pre-requisites:-
Loops
Operators
Data Types
Objective:-
To understand the concept of
• Continuous looping
• If-else constructs
• Type Casting
Team Emertxe
Thank you

More Related Content

Similar to 05_AP_GP_HP.pdf

Data Analytics Project_Eun Seuk Choi (Eric)
Data Analytics Project_Eun Seuk Choi (Eric)Data Analytics Project_Eun Seuk Choi (Eric)
Data Analytics Project_Eun Seuk Choi (Eric)
Eric Choi
 
Hidden Markov Model in Natural Language Processing
Hidden Markov Model in Natural Language ProcessingHidden Markov Model in Natural Language Processing
Hidden Markov Model in Natural Language Processing
sachinmaskeen211
 

Similar to 05_AP_GP_HP.pdf (20)

Data Analytics Project_Eun Seuk Choi (Eric)
Data Analytics Project_Eun Seuk Choi (Eric)Data Analytics Project_Eun Seuk Choi (Eric)
Data Analytics Project_Eun Seuk Choi (Eric)
 
Anything You Can Do, I Can Do Better: Finding Expert Teams by CrewScoutCrewsc...
Anything You Can Do, I Can Do Better: Finding Expert Teams by CrewScoutCrewsc...Anything You Can Do, I Can Do Better: Finding Expert Teams by CrewScoutCrewsc...
Anything You Can Do, I Can Do Better: Finding Expert Teams by CrewScoutCrewsc...
 
Arithmetic sequence.ppt
Arithmetic sequence.pptArithmetic sequence.ppt
Arithmetic sequence.ppt
 
How-to-illustrate-A.S.pptx
How-to-illustrate-A.S.pptxHow-to-illustrate-A.S.pptx
How-to-illustrate-A.S.pptx
 
06_x_pattern.pdf
06_x_pattern.pdf06_x_pattern.pdf
06_x_pattern.pdf
 
15_remove_duplicates.pdf
15_remove_duplicates.pdf15_remove_duplicates.pdf
15_remove_duplicates.pdf
 
LINEAR PROGRAMMING-Arithmetic Sequences
LINEAR PROGRAMMING-Arithmetic SequencesLINEAR PROGRAMMING-Arithmetic Sequences
LINEAR PROGRAMMING-Arithmetic Sequences
 
Algebra 2 unit 12.3.12.5
Algebra 2 unit 12.3.12.5Algebra 2 unit 12.3.12.5
Algebra 2 unit 12.3.12.5
 
Hidden Markov Model in Natural Language Processing
Hidden Markov Model in Natural Language ProcessingHidden Markov Model in Natural Language Processing
Hidden Markov Model in Natural Language Processing
 
(678215997) neethutext
(678215997) neethutext(678215997) neethutext
(678215997) neethutext
 
Algorithm and psuedocode
Algorithm and psuedocodeAlgorithm and psuedocode
Algorithm and psuedocode
 
Program flash 12 led dan 2 port slideshre
Program flash 12 led dan 2 port slideshreProgram flash 12 led dan 2 port slideshre
Program flash 12 led dan 2 port slideshre
 
L16
L16L16
L16
 
Part 1 sequence and arithmetic progression
Part 1 sequence and arithmetic progressionPart 1 sequence and arithmetic progression
Part 1 sequence and arithmetic progression
 
CBSE Class XI Maths Arthmetic progression
CBSE Class XI Maths Arthmetic progressionCBSE Class XI Maths Arthmetic progression
CBSE Class XI Maths Arthmetic progression
 
Arithmetic sequences and series
Arithmetic sequences and seriesArithmetic sequences and series
Arithmetic sequences and series
 
13_median.pdf
13_median.pdf13_median.pdf
13_median.pdf
 
Data structure algorithm
Data structure algorithmData structure algorithm
Data structure algorithm
 
Sequence and Series
Sequence and SeriesSequence and Series
Sequence and Series
 
Arithmetic progressions
Arithmetic progressionsArithmetic progressions
Arithmetic progressions
 

More from Emertxe Information Technologies Pvt Ltd

More from Emertxe Information Technologies Pvt Ltd (20)

premium post (1).pdf
premium post (1).pdfpremium post (1).pdf
premium post (1).pdf
 
Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
 
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
09_nrps.pdf
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
 
07_strtok.pdf
07_strtok.pdf07_strtok.pdf
07_strtok.pdf
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

05_AP_GP_HP.pdf