Pages

💡 Now You Can Get your Assignments Sollution here... .💡 100% plagiarism Free Service...💡 Responsibility, punctuality and on-time delivery... 💡 Furnishing you with experts... 💡 experienced in your subject 100% privacy... 💡 helping you with the highest efficiency , professionalism Affordable and budget-friendly costs that do not make a hole in your wallet

Write a C++ program for the following problem. Initialize an integer array A [] of size 5 in declaration.{ Assign the address of first element of array A[] to pointer variable ptr. Using pointer variable find and display the maximum and the minimum element of the array.



#include<iostream>
using namespace std;
int main()
{
int a[5];
for(int i=0; i<5; i++)
{
cin>>a[i];
}
  int *p,minimum=a[0],maximum=a[0];
  for(int i=0;i<5;i++)
  {
  p=&a[i];
  if(*p<minimum)
minimum=*p;
else if (*p>maximum)
maximum=*p;
}
cout<<"minimum : "<<minimum<<"  maximum : "<<maximum<<endl;
return 0;
}

No comments: