Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
find the max of five numbers using C++
+1
vote
asked
Feb 10, 2020
by
anonymous
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
2 Answers
0
votes
answered
Feb 13, 2020
by
Sirisha
(
140
points)
#include<iostream>
using namespace std;
int main()
{
int a[10]={1,5,2,3,4},i,b;
for(i=0;i<5;i++)
{
if(a[i]>a[i+1])
{
b=a[i];
a[i]=a[i+1];
a[i+1]=b;
}
}
cout<<b;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
Feb 15, 2020
by
Sai Naveen Chowdary
(
140
points)
# include<iostream>
using namespace std;
const int values = 30;
int main ()
{
int num[values];
int max , i;
cout << "Please enter 5 numbers, so that i show you the maximum \n";
cin >> num[0] >>num[1] >>num[2] >> num[3] >>num[4];
max = num[0];
for (int i=0; i<5; i++)
if (max < num[i])
max = num[i];
cout << "The maxmum value is:" << max << endl ;
system ("pause");
return 0;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...