1. Write a float function rectangle() that computes and returns the area of a rectangle using its two float formal parameters h and w, where h is the height and w is the width of the rectangle.
2. Write a function called isEven() that uses the remainder operator(%) to determine whether an integer is even or not.
3. Write a program with function name "ourmemeber" that displays your group members name and Id No correctly. Give example with random names and id.
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <iomanip>
using namespace std;
float rectangle (float h, float w) {
  return h * w;
}
bool isEven (int n) {
  return n % 2 == 0 ? true : false;
}
void ourmember (int n) {
  srand(time(0));
  string names[10] = {"John", "Eyler", "Nyuton", "Liza", "Eiyshli", "Scoffield", "Kasper", "Mike", "Eliza", "Jack"};
  cout << setw(20) << "Member Name |" << setw(20) << "Member Id |" << endl;
  for (int i = 0; i < n; i++) {
    int index = rand() % 10;
    int id = rand() % 900000 + 100000;
    cout << setw(18) << names[index] << " |" << setw(18) << id << " |\n";Â
  }
}
int main () {
  float height, width;
  cout << "Enter height of rectangle: "; cin >> height;
  cout << "Enter width of rectangle: "; cin >> width;
  float area;
  area = rectangle(height, width);
  cout << "Area of rectangle is: " << area << endl;
  int integer;
  cout << "Enter a integer: "; cin >> integer;
  if (isEven(integer)) {
    cout << "Entered integer is even\n";
  }
  else {
    cout << "Entered integer isn't even\n";
  }
  int n;
  cout << "How many people in your group: "; cin >> n;
  ourmember(n);
}
Comments
Leave a comment