Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
proDev-Theron
PLM-PLD_ClassWorks
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
PLM-PLD_ClassWorks
/
PLD_Find_the_largest_element_array.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
36 lines (34 loc) · 1.4 KB
main
Breadcrumbs
PLM-PLD_ClassWorks
/
PLD_Find_the_largest_element_array.cpp
Copy path
Top
File metadata and controls
Code
Blame
36 lines (34 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
/*
Created by Theron Adrianne Bueno
January 16, 2021
Subject: Programming Logic and Design (CPE 0112.1) - Pamantasan ng Lungsod ng Maynila (PLM)
Task: Write a program to find the largest element in the array.
*/
using namespace std;
int main()
{
int arrSize = 0; // initial value to avoid random values
int highest = 0; // variable to store the current largest value
cout << "Find the largest element in the array" << endl << endl;
cout << "=====================================================================" << endl;
cout << "Input the number of elements to be stored in the array";
cin >> arrSize; //store user input as array size of 'array1'
int array1[arrSize];
cout << "\nInput " << arrSize << " elements in the array: \n" << endl;
for (int i=0; i<arrSize; i++)
{
cout << "Input value for element "<< i << ": ";
cin >> array1[i];
}
highest = array1[0]; //Let the first input be the highest number. Let this be a reference point.
for(int i=1; i<arrSize; i++) //start with 1 because index 0 is the current value of 'highest'
{
//Loops through each element of the array and do the comparison.
if(array1[i] >= highest) //If this is true, the value of 'array1[i]' will be the new value of highest
{
highest = array1[i];
}
}
cout << "\nThe largest element in the array is: " << highest ;
}
You can’t perform that action at this time.