Menu

Sunday, 30 November 2014

Chapter 7,Problem 4:Object Oriented Programming by Robert Lafore in C++ Solution Manual

//Ahmad Furqan Attari
//p7.4
#include <iostream>
#include <conio.h>
using namespace std;
const int SIZE = 10;
int maxint(int (&num)[SIZE],int max)
{
 int large=num[0],index=0;
 for (int i = 1; i < max; i++)
 {
  if (num[i]>large)
  {
   large = num[i];
   index = i;
  }
 }
 return index;
}
void main(void)
{
 int num[SIZE];
 char ch;
 int i = 0;
 do
 {
  cout << "Enter a number: ";
  cin >> num[i];
  i++;
  cout << "Enter again?(y/n): ";
  ch = _getche();
  cout << endl;
 } while (ch == 'y' && i < SIZE);
 cout << "Greatest number entered: " << num[maxint(num,i)];
 _getch();
}

4 comments:

  1. plz i need a solution of chap 6 prblm 4 by robert lofer

    ReplyDelete
  2. https://github.com/phoenixx1/Robert-Lafore

    ReplyDelete
  3. Plz j needd a solution of ch 7 problems by robert lofer

    ReplyDelete