SlideShare a Scribd company logo
C++: Find the largest complex number in an array using recursive method. The largest number is
the one who has the largest (real)*(real) + (img)*(img)
Solution
#include
using namespace std;
class Complex
{
public:
float real;
float img;
Complex()
{
real = img = 0.0;
}
Complex(float real,float img)
{
this->real = real;
this->img = img;
}
};
void findLargest(Complex arr[],int size,Complex &max)
{
if(size==0)
return;
else
{
float val = arr[size-1].real*arr[size-1].real+arr[size-1].img*arr[size-1].img;
float maxval = max.real*max.real+max.img*max.img;
if(val>maxval)
max = arr[size];
return findLargest(arr,size-1,max);
}
}
int main() {
// your code goes here
Complex c1(4,4);
Complex c2(5,5);
Complex arr[2];
arr[0] = c1;
arr[1] = c2;
Complex max;
findLargest(arr,2,max);
cout << "Max complex number is : " << max.real << " + i"<< max.img;
return 0;
}

More Related Content

Similar to C++ Find the largest complex number in an array using recursive met.pdf

Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1IIUM
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
Farhan Ab Rahman
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
JumanneChiyanda
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdf
arihantstoneart
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
Education Front
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
SaadAsim11
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
Computer Programming- Lecture 9
Computer Programming- Lecture 9Computer Programming- Lecture 9
Computer Programming- Lecture 9
Dr. Md. Shohel Sayeed
 
The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212
Mahmoud Samir Fayed
 
Java programs
Java programsJava programs
Java programsjojeph
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
kamdinrossihoungma74
 
Chap 6 c++
Chap 6 c++Chap 6 c++
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
Egor Bogatov
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick Reference
Seung-Bum Lee
 
Chap 6 c++
Chap 6 c++Chap 6 c++
The Ring programming language version 1.7 book - Part 40 of 196
The Ring programming language version 1.7 book - Part 40 of 196The Ring programming language version 1.7 book - Part 40 of 196
The Ring programming language version 1.7 book - Part 40 of 196
Mahmoud Samir Fayed
 

Similar to C++ Find the largest complex number in an array using recursive met.pdf (20)

Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1Csc1100 lecture07 ch07_pt1-1
Csc1100 lecture07 ch07_pt1-1
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
Describe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdfDescribe a data structure that supports both removeMin() and rem.pdf
Describe a data structure that supports both removeMin() and rem.pdf
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
 
Computer Programming- Lecture 9
Computer Programming- Lecture 9Computer Programming- Lecture 9
Computer Programming- Lecture 9
 
The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212
 
Java programs
Java programsJava programs
Java programs
 
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdfPart 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
Part 1 - Written AnswersDownload the GridWriter.zip file and exami.pdf
 
Chapter 6 arrays part-1
Chapter 6   arrays part-1Chapter 6   arrays part-1
Chapter 6 arrays part-1
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick Reference
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
The Ring programming language version 1.7 book - Part 40 of 196
The Ring programming language version 1.7 book - Part 40 of 196The Ring programming language version 1.7 book - Part 40 of 196
The Ring programming language version 1.7 book - Part 40 of 196
 

More from alvisguyjhiy

Explain in details three of the technological impacts that we must b.pdf
Explain in details three of the technological impacts that we must b.pdfExplain in details three of the technological impacts that we must b.pdf
Explain in details three of the technological impacts that we must b.pdf
alvisguyjhiy
 
Describe the shapestructure of lymph nodes. Make a note of where co.pdf
Describe the shapestructure of lymph nodes. Make a note of where co.pdfDescribe the shapestructure of lymph nodes. Make a note of where co.pdf
Describe the shapestructure of lymph nodes. Make a note of where co.pdf
alvisguyjhiy
 
Describe fin placement as it relates to the maintenance of position i.pdf
Describe fin placement as it relates to the maintenance of position i.pdfDescribe fin placement as it relates to the maintenance of position i.pdf
Describe fin placement as it relates to the maintenance of position i.pdf
alvisguyjhiy
 
Database Management Systema. What are the 2 valid reasons to form.pdf
Database Management Systema. What are the 2 valid reasons to form.pdfDatabase Management Systema. What are the 2 valid reasons to form.pdf
Database Management Systema. What are the 2 valid reasons to form.pdf
alvisguyjhiy
 
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdf
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdfCompare and Discuss the Differences between Jean Piaget’s Stages of .pdf
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdf
alvisguyjhiy
 
Chapter 11, Q2What types of products might not benefit from ID in.pdf
Chapter 11, Q2What types of products might not benefit from ID in.pdfChapter 11, Q2What types of products might not benefit from ID in.pdf
Chapter 11, Q2What types of products might not benefit from ID in.pdf
alvisguyjhiy
 
Based on the human pedigree below, determine if the disease condition.pdf
Based on the human pedigree below, determine if the disease condition.pdfBased on the human pedigree below, determine if the disease condition.pdf
Based on the human pedigree below, determine if the disease condition.pdf
alvisguyjhiy
 
Background(Need help with problem in photo)Methanol is produced.pdf
Background(Need help with problem in photo)Methanol is produced.pdfBackground(Need help with problem in photo)Methanol is produced.pdf
Background(Need help with problem in photo)Methanol is produced.pdf
alvisguyjhiy
 
write a task statement from the list below1. organise and maintain.pdf
write a task statement from the list below1. organise and maintain.pdfwrite a task statement from the list below1. organise and maintain.pdf
write a task statement from the list below1. organise and maintain.pdf
alvisguyjhiy
 
Why is it so important that the CPU be allowed to do other tasks whil.pdf
Why is it so important that the CPU be allowed to do other tasks whil.pdfWhy is it so important that the CPU be allowed to do other tasks whil.pdf
Why is it so important that the CPU be allowed to do other tasks whil.pdf
alvisguyjhiy
 
What test do I use when checking for significance between two variab.pdf
What test do I use when checking for significance between two variab.pdfWhat test do I use when checking for significance between two variab.pdf
What test do I use when checking for significance between two variab.pdf
alvisguyjhiy
 
What is the very beginning of an frame called Header Data Tr.pdf
What is the very beginning of an  frame called  Header  Data  Tr.pdfWhat is the very beginning of an  frame called  Header  Data  Tr.pdf
What is the very beginning of an frame called Header Data Tr.pdf
alvisguyjhiy
 
6. What types of epithelia would be suited for the following functio.pdf
6. What types of epithelia would be suited for the following functio.pdf6. What types of epithelia would be suited for the following functio.pdf
6. What types of epithelia would be suited for the following functio.pdf
alvisguyjhiy
 
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdfWhat is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
alvisguyjhiy
 
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
alvisguyjhiy
 
1. (1) Use the command to display the contents of a file one page at.pdf
1. (1) Use the command to display the contents of a file one page at.pdf1. (1) Use the command to display the contents of a file one page at.pdf
1. (1) Use the command to display the contents of a file one page at.pdf
alvisguyjhiy
 
Short questions The access time of memory is the time required for p.pdf
Short questions The access time of memory is the time required for p.pdfShort questions The access time of memory is the time required for p.pdf
Short questions The access time of memory is the time required for p.pdf
alvisguyjhiy
 
Red-green color blindness is a human X-linked recessive disorder. A y.pdf
Red-green color blindness is a human X-linked recessive disorder. A y.pdfRed-green color blindness is a human X-linked recessive disorder. A y.pdf
Red-green color blindness is a human X-linked recessive disorder. A y.pdf
alvisguyjhiy
 
Question 1- what secondary storage devices are appropriate ... Save.pdf
Question 1- what secondary storage devices are appropriate ... Save.pdfQuestion 1- what secondary storage devices are appropriate ... Save.pdf
Question 1- what secondary storage devices are appropriate ... Save.pdf
alvisguyjhiy
 
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdf
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdfMnemonics are useful memory aids. Construct a mnemonic for the five .pdf
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdf
alvisguyjhiy
 

More from alvisguyjhiy (20)

Explain in details three of the technological impacts that we must b.pdf
Explain in details three of the technological impacts that we must b.pdfExplain in details three of the technological impacts that we must b.pdf
Explain in details three of the technological impacts that we must b.pdf
 
Describe the shapestructure of lymph nodes. Make a note of where co.pdf
Describe the shapestructure of lymph nodes. Make a note of where co.pdfDescribe the shapestructure of lymph nodes. Make a note of where co.pdf
Describe the shapestructure of lymph nodes. Make a note of where co.pdf
 
Describe fin placement as it relates to the maintenance of position i.pdf
Describe fin placement as it relates to the maintenance of position i.pdfDescribe fin placement as it relates to the maintenance of position i.pdf
Describe fin placement as it relates to the maintenance of position i.pdf
 
Database Management Systema. What are the 2 valid reasons to form.pdf
Database Management Systema. What are the 2 valid reasons to form.pdfDatabase Management Systema. What are the 2 valid reasons to form.pdf
Database Management Systema. What are the 2 valid reasons to form.pdf
 
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdf
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdfCompare and Discuss the Differences between Jean Piaget’s Stages of .pdf
Compare and Discuss the Differences between Jean Piaget’s Stages of .pdf
 
Chapter 11, Q2What types of products might not benefit from ID in.pdf
Chapter 11, Q2What types of products might not benefit from ID in.pdfChapter 11, Q2What types of products might not benefit from ID in.pdf
Chapter 11, Q2What types of products might not benefit from ID in.pdf
 
Based on the human pedigree below, determine if the disease condition.pdf
Based on the human pedigree below, determine if the disease condition.pdfBased on the human pedigree below, determine if the disease condition.pdf
Based on the human pedigree below, determine if the disease condition.pdf
 
Background(Need help with problem in photo)Methanol is produced.pdf
Background(Need help with problem in photo)Methanol is produced.pdfBackground(Need help with problem in photo)Methanol is produced.pdf
Background(Need help with problem in photo)Methanol is produced.pdf
 
write a task statement from the list below1. organise and maintain.pdf
write a task statement from the list below1. organise and maintain.pdfwrite a task statement from the list below1. organise and maintain.pdf
write a task statement from the list below1. organise and maintain.pdf
 
Why is it so important that the CPU be allowed to do other tasks whil.pdf
Why is it so important that the CPU be allowed to do other tasks whil.pdfWhy is it so important that the CPU be allowed to do other tasks whil.pdf
Why is it so important that the CPU be allowed to do other tasks whil.pdf
 
What test do I use when checking for significance between two variab.pdf
What test do I use when checking for significance between two variab.pdfWhat test do I use when checking for significance between two variab.pdf
What test do I use when checking for significance between two variab.pdf
 
What is the very beginning of an frame called Header Data Tr.pdf
What is the very beginning of an  frame called  Header  Data  Tr.pdfWhat is the very beginning of an  frame called  Header  Data  Tr.pdf
What is the very beginning of an frame called Header Data Tr.pdf
 
6. What types of epithelia would be suited for the following functio.pdf
6. What types of epithelia would be suited for the following functio.pdf6. What types of epithelia would be suited for the following functio.pdf
6. What types of epithelia would be suited for the following functio.pdf
 
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdfWhat is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
What is an autotrophic bacteriumSolutionAutotrophic Bacteria.pdf
 
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
1. mtDNA-associated Leigh syndrome affects the brain of afflicted in.pdf
 
1. (1) Use the command to display the contents of a file one page at.pdf
1. (1) Use the command to display the contents of a file one page at.pdf1. (1) Use the command to display the contents of a file one page at.pdf
1. (1) Use the command to display the contents of a file one page at.pdf
 
Short questions The access time of memory is the time required for p.pdf
Short questions The access time of memory is the time required for p.pdfShort questions The access time of memory is the time required for p.pdf
Short questions The access time of memory is the time required for p.pdf
 
Red-green color blindness is a human X-linked recessive disorder. A y.pdf
Red-green color blindness is a human X-linked recessive disorder. A y.pdfRed-green color blindness is a human X-linked recessive disorder. A y.pdf
Red-green color blindness is a human X-linked recessive disorder. A y.pdf
 
Question 1- what secondary storage devices are appropriate ... Save.pdf
Question 1- what secondary storage devices are appropriate ... Save.pdfQuestion 1- what secondary storage devices are appropriate ... Save.pdf
Question 1- what secondary storage devices are appropriate ... Save.pdf
 
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdf
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdfMnemonics are useful memory aids. Construct a mnemonic for the five .pdf
Mnemonics are useful memory aids. Construct a mnemonic for the five .pdf
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

C++ Find the largest complex number in an array using recursive met.pdf

  • 1. C++: Find the largest complex number in an array using recursive method. The largest number is the one who has the largest (real)*(real) + (img)*(img) Solution #include using namespace std; class Complex { public: float real; float img; Complex() { real = img = 0.0; } Complex(float real,float img) { this->real = real; this->img = img; } }; void findLargest(Complex arr[],int size,Complex &max) { if(size==0) return; else { float val = arr[size-1].real*arr[size-1].real+arr[size-1].img*arr[size-1].img; float maxval = max.real*max.real+max.img*max.img; if(val>maxval) max = arr[size];
  • 2. return findLargest(arr,size-1,max); } } int main() { // your code goes here Complex c1(4,4); Complex c2(5,5); Complex arr[2]; arr[0] = c1; arr[1] = c2; Complex max; findLargest(arr,2,max); cout << "Max complex number is : " << max.real << " + i"<< max.img; return 0; }