Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

kindly solve this question for "LIFE SAVER POINTS"...

Know the answer? Have a better solution? Share it.
Sign Up Now for FREE!
Join the thousands of students
getting ahead in their classes.
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Rookie
Karma Points: 0
Respect (60%):
Date Posted: 7/22/2008 7:23:32 AM  Status: Live
kindly solve this question for "LIFE SAVER POINTS"...
Course Textbook Chapter Problem
N/A Object Oriented Programing N/A N/A
Question Details:
 

Question

Create a function called amax() that returns the value of the largest element in an array. The arguments to the function should be the address of the array and its size. Make this function into a template so it will work with an array of any numerical type. Write a main() program that applies this function to arrays of various types

Answers:

Member's Avatar

Guru
Karma Points: 2,019
Date Posted: 7/22/2008 8:59:52 AM  Status: Live
Asker's Rating: Helpful   
Response:
Note: Your require program is given bellow in step wise.

#include <iostream>
using namespace std;
const int SIZE = 50;
/* Function Prototypes */
void readdata(int [ ], int &);
int sumarray(int [ ], int);
double avgarray(int [ ], int);
int findmax(int [ ], int);

 
int main()
{   
   int num;
int mark[SIZE];
double avgmark;
int numabove,numbelow,numequal,hi_mark;
// call function to read the marks and print the array
readdata(mark,num);
// print the mark array
for (count = 0; count < num; count++)
cout<<“mark[“<<count<<“]=”<<mark[count] << endl;
// find and print the average mark
avgmark = avgarray(mark,num);
cout <<endl<< "The average is “ << avgmark <<endl;
// find and print the highest mark
hi_mark = findmax(mark,num);
cout << "The highest mark is “ << hi_mark << endl;
return 0;
}
 
void readdata(int numbers[ ], int &n)
{
cout << "Enter the number of marks: ";
cin >> n;
for (int count = 0; count < n; count++) {
cout << "Enter a mark: ";
cin >> numbers[count];
}
return;
}
 
int sumarray(int numbers[ ], int n)
{
int sum=0;
for (int count = 0; count < n; count++)
sum += numbers[count];
return(sum);
}
 
double avgarray(int numbers[], int n)
{
return ((double)sumarray(numbers,n)/n);
}
 
int findmax(int numbers[], int n)
{
int largest_so_far;
largest_so_far = numbers[0];
for (int count = 1; count < n; count++)
if (largest_so_far < numbers[count])
largest_so_far = numbers[count];
return(largest_so_far);
}
badshah's Comment:
THANKS

Hope this will help you,
Don't forget to LIFE SAVER RATE to my answer plz.

Ziaxp (MIT)


Cramster Expert

Member's Avatar

(Cramster SME)
Moderator
Cramster In-House Subject Matter Expert
Date Posted: 7/24/2008 6:34:46 AM  Status: Live
Asker's Rating: Lifesaver   
Response:
 
Dear User

Hope the following solution program will help you. Still need any assistance / clarification ? Remember! CRAMSTER is always there to SOLVE PROBLEMS.
 
badshah's Comment:
THANKS HELP ME AGAIN



By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.