Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the 4 main oop principles?

1268


What polymorphism means?

1135


Why is static class not inherited?

1152


There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.

2054


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1920


What does <> mean pseudocode?

1262


What is purpose of inheritance?

1171


What makes a language oop?

1130


What language is oop?

1075


Why do we use polymorphism in oops?

1108


Is this job good for future? can do this job post grduate student?

2221


What is constructor in oop?

1173


design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)

6732


Why is abstraction needed?

1095


Why we use classes in oop?

1097