write a function that takes an integer array as an input and
finds the largest number in the array. You can not sort
array or use any API or searching needs?
Answer Posted / pawan
By using dynamic memory allocation..............
#include<iostream>
#include<new>
using namespace std;
int main()
{
int big,i,*p,sz;
cout << "Enter the size of an array u wanted:";
cin >> sz;
try {
p = new int(sz);
}catch(bad_alloc xa) {
cout << "allocation failure";
return 1;
}
for(i=0; i<sz; i++) {
cout << "Enter a value" << i << ":";
cin >> p[i];
}
cout << "name contains:";
for(i=0; i<sz; i++) {
cout << p[i]<< "\n";
}
big = p[0];
for(i = 0; i < sz; i++) {
if(p[i] > big)
big = p[i];
}
cout << "The Bigest Number::" << big << endl;
return 0;
}
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
how to get the oracle certification? send me the answer
How is polymorphism achieved?
Whats is abstraction in oops?
What does oop mean in snapchat?
How to call a non virtual function in the derived class by using base class pointer
Please send ford technologies placement paper 2 my mail id
How can you overcome the diamond problem in inheritance?
What is balance factor?
What is the purpose of polymorphism?
What is overloading in oop?
What does it mean when someone says I oop?
What are the two different types of polymorphism?
hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.
How do you answer polymorphism?
How do you explain polymorphism?