SlideShare a Scribd company logo
Update
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Control {
private:
int arr[1000];
int size = 1000;
public:
Control() {
srand(time(NULL));
ifstream file("numbers.txt");
if (file.is_open()) {
for (int i = 0; i < size; i++) {
file >> arr[i];
}
file.close();
}
else {
cout << "Unable to open file." << endl;
}
for (int i = 0; i < size; i++) {
arr[i] = rand() % 1000 + 1;
}
}
void outputAll() {
for (int i = 0; i < size; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
void outputSum() {
int sum = 0;
for (int i = 0; i < size; i++) {
sum += arr[i];
}
cout << "Sum: " << sum << endl;
}
void outputOdd() {
cout << "Odd numbers: ";
for (int i = 0; i < size; i++) {
if (arr[i] % 2 != 0) {
cout << arr[i] << " ";
}
}
cout << endl;
}
void outputEven() {
cout << "Even numbers: ";
for (int i = 0; i < size; i++) {
if (arr[i] % 2 == 0) {
cout << arr[i] << " ";
}
}
cout << endl;
}
void linearSearch(int val) {
bool found = false;
for (int i = 0; i < size; i++) {
if (arr[i] == val) {
found = true;
cout << "Value found at index " << i << endl;
break;
}
}
if (!found) {
cout << "Value not found." << endl;
}
}
void outputMiddle() {
int middle = size / 2;
cout << "Middle value(s): ";
if (size % 2 == 0) {
cout << arr[middle - 1] << " " << arr[middle] << endl;
}
else {
cout << arr[middle] << endl;
}
}
void outputFirst() {
cout << "First value: " << arr[0] << endl;
}
void outputLast() {
cout << "Last value: " << arr[size - 1] << endl;
}
void outputHighest() {
int highest = arr[0];
int index = 0;
for (int i = 1; i < size; i++) {
if (arr[i] > highest) {
highest = arr[i];
index = i;
}
}
cout << "Highest value: " << highest << " (index " << index << ")" << endl;
}
void outputLowest() {
int lowest = arr[0];
int index = 0;
for (int i = 1; i < size; i++) {
if (arr[i] < lowest) {
lowest = arr[i];
index = i;
}
}
cout << "Lowest value: " << lowest << " (index " << index << ")" << endl;
}
void bubbleSort() {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
cout << "Array sorted in ascending order using bubble sort." << endl;
}
};
int main(){
Control c;
c.outputAll();
c.outputSum();
c.outputOdd();
c.outputEven();
c.outputFirst();
c.outputLast();
c.outputMiddle();
c.linearSearch();
c.outputLowest();
c.outputHighest();
}
Create a conventional structure for C++ Program
Header File (Outline / Framework of C++ Class File)
Driver File (File Containing Main Function)
Class Implementation File
Make Sure all the files are organized in the same directory.
Main Function: Control of operation
Common_Alg
The array will be a Class Variable {Implement Dynamic array)
In your Class declare and fill an array with 1000 random integers between 1 - 1000 from your .txt
file used in previous tasks.
Filling the array with random integers should happen in the class constructor.
***Hint: use the class constructor.
The algorithm outputs below should remain the same.
Implement Binary Search algorithm instead of Linear Search Algorithm
Directory Holding Header File / Driver File / Class Implementation File:
Attach Snipping Photo of Command Line Navigation and Files in the Directory
Main Function:
Attach a snipping photo of source code
Class Constructor:
Attach a snipping photo of source code
Method 1: Output all values
Attach a snipping photo of source code and output
Method 2: Output sum All values
Attach a snipping photo of source code and output
Method 3: Output All odd numbers
Attach a snipping photo of source code and output
Method 4: Output All Even numbers
Attach a snipping photo of source code and output
Method 5: Enter a search value /Binary Search
New
Attach a snipping photo of source code and output
Method 6: Output Middle Value (Values in the Middle)
Not Average
New
Attach a snipping photo of source code and output
Method 7: Output First Value in the Array
New
Attach a snipping photo of source code and output
Method 8: Output Last Value in the Array
New
Attach a snipping photo of source code and output
Method 9: Output the Highest Value and its location in the array. (Hardcode the algorithm.)
New
Attach a snipping photo of the source code and output
Method 10: Output the Lowest Value and its location in the array. (Hardcode the algorithm.)
New
Attach a snipping photo of source code and output
Method 11:
Bubble Sort
New
Attach a snipping photo of source code and output
Directory Holding Header File / Driver File / Class Implementation File:
Attach Snipping Photo of Command Line Navigation and Files in the Directory
Main Function:
Attach a snipping photo of source code
Class Constructor:
Attach a snipping photo of source code
Method 1: Output all values
Attach a snipping photo of source code and output
Method 2: Output sum All values
Attach a snipping photo of source code and output
Method 3: Output All odd numbers
Attach a snipping photo of source code and output
Method 4: Output All Even numbers
Attach a snipping photo of source code and output
Method 5: Enter a search value /Binary Search
New
Attach a snipping photo of source code and output
Method 6: Output Middle Value (Values in the Middle)
Not Average
New
Attach a snipping photo of source code and output
Method 7: Output First Value in the Array
New
Attach a snipping photo of source code and output
Method 8: Output Last Value in the Array
New
Attach a snipping photo of source code and output
Method 9: Output the Highest Value and its location in the array. (Hardcode the algorithm.)
New
Attach a snipping photo of the source code and output
Method 10: Output the Lowest Value and its location in the array. (Hardcode the algorithm.)
New
Attach a snipping photo of source code and output
Method 11:
Bubble Sort
New
Attach a snipping photo of source code and output

More Related Content

Similar to Update include ltiostreamgt include ltfstreamgt .pdf

Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
Marco Izzotti
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
vikram mahendra
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docxAssignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
braycarissa250
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
Ûťţåm Ğűpţä
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
Mahmoud Samir Fayed
 
Object Oriented Programming using C++: C++ Templates.pptx
Object Oriented Programming using C++: C++ Templates.pptxObject Oriented Programming using C++: C++ Templates.pptx
Object Oriented Programming using C++: C++ Templates.pptx
RashidFaridChishti
 
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
Java practical
Java practicalJava practical
Java practical
william otto
 
OOPS 22-23 (1).pptx
OOPS 22-23 (1).pptxOOPS 22-23 (1).pptx
OOPS 22-23 (1).pptx
SushmaGavaraskar
 
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
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
Pranav Ghildiyal
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
SirRafiLectures
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
 
Please follow the code and comments for description a)CODE #.pdf
Please follow the code and comments for description a)CODE #.pdfPlease follow the code and comments for description a)CODE #.pdf
Please follow the code and comments for description a)CODE #.pdf
annaindustries
 

Similar to Update include ltiostreamgt include ltfstreamgt .pdf (20)

Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docxAssignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
Assignment 13assg-13.cppAssignment 13assg-13.cpp   @auth.docx
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Object Oriented Programming using C++: C++ Templates.pptx
Object Oriented Programming using C++: C++ Templates.pptxObject Oriented Programming using C++: C++ Templates.pptx
Object Oriented Programming using C++: C++ Templates.pptx
 
C++ practical
C++ practicalC++ practical
C++ practical
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Java practical
Java practicalJava practical
Java practical
 
OOPS 22-23 (1).pptx
OOPS 22-23 (1).pptxOOPS 22-23 (1).pptx
OOPS 22-23 (1).pptx
 
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
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Please follow the code and comments for description a)CODE #.pdf
Please follow the code and comments for description a)CODE #.pdfPlease follow the code and comments for description a)CODE #.pdf
Please follow the code and comments for description a)CODE #.pdf
 

More from adityacommunications2

US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdfUS Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
adityacommunications2
 
US set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdfUS set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdf
adityacommunications2
 
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdfURINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
adityacommunications2
 
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdfUS Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
adityacommunications2
 
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdfUS Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
adityacommunications2
 
Urgent Draw the EER diagram for the Hiking Database given .pdf
Urgent  Draw the EER diagram for the Hiking Database given .pdfUrgent  Draw the EER diagram for the Hiking Database given .pdf
Urgent Draw the EER diagram for the Hiking Database given .pdf
adityacommunications2
 
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdfUpan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
adityacommunications2
 
UPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdfUPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdf
adityacommunications2
 
Underground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdfUnderground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdf
adityacommunications2
 
Update the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdfUpdate the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdf
adityacommunications2
 
Understand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdfUnderstand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdf
adityacommunications2
 
Unlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdfUnlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdf
adityacommunications2
 
Unemployment which is when persons in an economy have lost.pdf
Unemployment  which is when persons in an economy have lost.pdfUnemployment  which is when persons in an economy have lost.pdf
Unemployment which is when persons in an economy have lost.pdf
adityacommunications2
 
Unknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdfUnknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdf
adityacommunications2
 
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdfUna moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
adityacommunications2
 
Una persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdfUna persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdf
adityacommunications2
 
Una forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdfUna forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdf
adityacommunications2
 
Una fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdfUna fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdf
adityacommunications2
 
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdfUnit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
adityacommunications2
 
Una enfermera est cuidando a un cliente adulto mayor La e.pdf
Una enfermera est cuidando a un cliente adulto mayor La e.pdfUna enfermera est cuidando a un cliente adulto mayor La e.pdf
Una enfermera est cuidando a un cliente adulto mayor La e.pdf
adityacommunications2
 

More from adityacommunications2 (20)

US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdfUS Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
 
US set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdfUS set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdf
 
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdfURINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
 
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdfUS Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
 
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdfUS Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
 
Urgent Draw the EER diagram for the Hiking Database given .pdf
Urgent  Draw the EER diagram for the Hiking Database given .pdfUrgent  Draw the EER diagram for the Hiking Database given .pdf
Urgent Draw the EER diagram for the Hiking Database given .pdf
 
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdfUpan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
 
UPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdfUPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdf
 
Underground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdfUnderground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdf
 
Update the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdfUpdate the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdf
 
Understand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdfUnderstand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdf
 
Unlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdfUnlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdf
 
Unemployment which is when persons in an economy have lost.pdf
Unemployment  which is when persons in an economy have lost.pdfUnemployment  which is when persons in an economy have lost.pdf
Unemployment which is when persons in an economy have lost.pdf
 
Unknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdfUnknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdf
 
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdfUna moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
 
Una persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdfUna persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdf
 
Una forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdfUna forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdf
 
Una fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdfUna fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdf
 
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdfUnit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
 
Una enfermera est cuidando a un cliente adulto mayor La e.pdf
Una enfermera est cuidando a un cliente adulto mayor La e.pdfUna enfermera est cuidando a un cliente adulto mayor La e.pdf
Una enfermera est cuidando a un cliente adulto mayor La e.pdf
 

Recently uploaded

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
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
 
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
 
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 Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
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
 
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
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
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
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
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
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
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
 

Recently uploaded (20)

Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
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
 
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
 
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 Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
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
 
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
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
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
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
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
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
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
 

Update include ltiostreamgt include ltfstreamgt .pdf

  • 1. Update #include <iostream> #include <fstream> #include <cstdlib> #include <ctime> using namespace std; class Control { private: int arr[1000]; int size = 1000; public: Control() { srand(time(NULL)); ifstream file("numbers.txt"); if (file.is_open()) { for (int i = 0; i < size; i++) { file >> arr[i]; } file.close(); } else { cout << "Unable to open file." << endl; } for (int i = 0; i < size; i++) { arr[i] = rand() % 1000 + 1; } } void outputAll() { for (int i = 0; i < size; i++) { cout << arr[i] << " "; } cout << endl; } void outputSum() { int sum = 0; for (int i = 0; i < size; i++) { sum += arr[i]; } cout << "Sum: " << sum << endl; } void outputOdd() { cout << "Odd numbers: ";
  • 2. for (int i = 0; i < size; i++) { if (arr[i] % 2 != 0) { cout << arr[i] << " "; } } cout << endl; } void outputEven() { cout << "Even numbers: "; for (int i = 0; i < size; i++) { if (arr[i] % 2 == 0) { cout << arr[i] << " "; } } cout << endl; } void linearSearch(int val) { bool found = false; for (int i = 0; i < size; i++) { if (arr[i] == val) { found = true; cout << "Value found at index " << i << endl; break; } } if (!found) { cout << "Value not found." << endl; } } void outputMiddle() { int middle = size / 2; cout << "Middle value(s): "; if (size % 2 == 0) { cout << arr[middle - 1] << " " << arr[middle] << endl; } else { cout << arr[middle] << endl; } } void outputFirst() { cout << "First value: " << arr[0] << endl; }
  • 3. void outputLast() { cout << "Last value: " << arr[size - 1] << endl; } void outputHighest() { int highest = arr[0]; int index = 0; for (int i = 1; i < size; i++) { if (arr[i] > highest) { highest = arr[i]; index = i; } } cout << "Highest value: " << highest << " (index " << index << ")" << endl; } void outputLowest() { int lowest = arr[0]; int index = 0; for (int i = 1; i < size; i++) { if (arr[i] < lowest) { lowest = arr[i]; index = i; } } cout << "Lowest value: " << lowest << " (index " << index << ")" << endl; } void bubbleSort() { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } cout << "Array sorted in ascending order using bubble sort." << endl; } }; int main(){ Control c; c.outputAll(); c.outputSum();
  • 4. c.outputOdd(); c.outputEven(); c.outputFirst(); c.outputLast(); c.outputMiddle(); c.linearSearch(); c.outputLowest(); c.outputHighest(); } Create a conventional structure for C++ Program Header File (Outline / Framework of C++ Class File) Driver File (File Containing Main Function) Class Implementation File Make Sure all the files are organized in the same directory. Main Function: Control of operation Common_Alg The array will be a Class Variable {Implement Dynamic array) In your Class declare and fill an array with 1000 random integers between 1 - 1000 from your .txt file used in previous tasks. Filling the array with random integers should happen in the class constructor. ***Hint: use the class constructor. The algorithm outputs below should remain the same. Implement Binary Search algorithm instead of Linear Search Algorithm Directory Holding Header File / Driver File / Class Implementation File: Attach Snipping Photo of Command Line Navigation and Files in the Directory Main Function: Attach a snipping photo of source code Class Constructor: Attach a snipping photo of source code Method 1: Output all values Attach a snipping photo of source code and output Method 2: Output sum All values Attach a snipping photo of source code and output Method 3: Output All odd numbers Attach a snipping photo of source code and output Method 4: Output All Even numbers Attach a snipping photo of source code and output Method 5: Enter a search value /Binary Search New Attach a snipping photo of source code and output Method 6: Output Middle Value (Values in the Middle) Not Average
  • 5. New Attach a snipping photo of source code and output Method 7: Output First Value in the Array New Attach a snipping photo of source code and output Method 8: Output Last Value in the Array New Attach a snipping photo of source code and output Method 9: Output the Highest Value and its location in the array. (Hardcode the algorithm.) New Attach a snipping photo of the source code and output Method 10: Output the Lowest Value and its location in the array. (Hardcode the algorithm.) New Attach a snipping photo of source code and output Method 11: Bubble Sort New Attach a snipping photo of source code and output Directory Holding Header File / Driver File / Class Implementation File: Attach Snipping Photo of Command Line Navigation and Files in the Directory Main Function: Attach a snipping photo of source code Class Constructor: Attach a snipping photo of source code Method 1: Output all values Attach a snipping photo of source code and output Method 2: Output sum All values Attach a snipping photo of source code and output Method 3: Output All odd numbers Attach a snipping photo of source code and output Method 4: Output All Even numbers Attach a snipping photo of source code and output Method 5: Enter a search value /Binary Search New Attach a snipping photo of source code and output Method 6: Output Middle Value (Values in the Middle) Not Average New Attach a snipping photo of source code and output
  • 6. Method 7: Output First Value in the Array New Attach a snipping photo of source code and output Method 8: Output Last Value in the Array New Attach a snipping photo of source code and output Method 9: Output the Highest Value and its location in the array. (Hardcode the algorithm.) New Attach a snipping photo of the source code and output Method 10: Output the Lowest Value and its location in the array. (Hardcode the algorithm.) New Attach a snipping photo of source code and output Method 11: Bubble Sort New Attach a snipping photo of source code and output