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

#include<iostream>
using namespace std;

int main()
{
int name[5],big,i;

for(i=0; i<=4; i++) {
cout << "Enter a value" << i << ":";
cin >> name[i];
}
cout << "name contains:";
for(i=0; i<=4; i++) {
cout << name[i]<< "\n";
}

big = name[0];
for(i = 0; i <= 4; i++) {
if(name[i] > big)
big = name[i];
}

cout << "The Bigest Number::" << big << endl;

return 0;
}

Is This Answer Correct ?    39 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between abstraction and polymorphism?

617


What is destructor example?

597


How long to learn object oriented programming?

565


What is abstract class in oops?

600


What is abstraction example?

624






How do you achieve polymorphism?

618


What is oops in simple words?

583


What are the 4 main oop principles?

685


Is enum a class?

607


What do you mean by Encapsulation?

642


if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?

2760


What is the real time example of inheritance?

643


Can bst contain duplicates?

670


Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation

1661


Why do we use polymorphism in oops?

581