Program for largest element in array using c++
Deletes all array elements in c++
int array[5],i,temp;
printf("\n enter element in array");
for(i=0;i<5;i++)
scanf("%d",&array);
for(i=1;i<5;i++)
{
if(array[0])
{
temp=array;
array=array[0];array[0]=temp;
}
}
printf("\n largest ele. in array=%d",temp);
getch();
}
we get array size 5 then enter 5 element in array..then tack temp variable before this we give separate 1st element in array to assign maximum element in array then compare it with one by one remaining element in array..if 1st ele in array is smaller than any one element in remaining array then print element in remaining array..else print 1st element in array.Deletes all array elements in c++
#include
class Date
{
int mo, da, yr;
public:
Date()
{
std::cout << "Date constructor" << std::endl;
}
~Date()
{ std::cout << "Date destructor" << std::endl;
}
};
int main()
{
Date* dt = new Date[5];
std::cout << "Process the dates";
std::endl;
// Deletes all five array elements. delete [] dt;
return 0;
}