Array and functions

Hello Guys. I did something but it's not correct. Can you adjust? Here is my question : Create array with 10 books(title, author, price, year of publication). Create functions for: entering data, printing data and output the book with min price and output the book with publication year after 1980.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  #include<iostream>
#include<string>

using namespace std;

struct book {
    string title;
    string author;
    double price;
    int year;
};

void create_data(book something[]);
void findabook(book something[]);
void findminprice(book something[]);



int main() {
    book something[10];
    create_data(something);
    cout << endl;
    findabook(something);
    findminprice(something);
}


void create_data(book something[])
{
    for (int i = 0; i < 10; i++)
    {
        cout << endl << "Please enter Book Title: ";
        getline(cin, something[i].title);
        cout << endl << "Please enter Book Author: ";
        getline(cin, something[i].author);
        cout << endl << "Please enter Book Price: ";
        cin >> something[i].price;
        cout << endl << "Please enter Book Year of Publication: ";
        cin >> something[i].year;
        cin.ignore(1000, '\n');
    }

}

void findabook(book something[])
{
    for (int i = 0; i < 10; i++)
        if (something[i].year > 1980)
        {
            cout << endl << "Author of the book with publication year after 1980 is:" << something[i].author;
            cout << endl << "Title of the book with publication year after 1980 is:" << something[i].title;
            cout << endl << "Price of the book with publication year after 1980 is:" << something[i].price;
            cout << endl << "The book publication year is:" << something[i].year;
        }

}




void findminprice(book something[])
{
    book min;
    min = something[0];
    for (int i = 1; i < 10; i++)
        if (something[i].price < min.price)
            min = something[i];
    cout << endl << "Book with min price is : " << min.price;
}
what does it not do correctly?
the min price may not print enough info to recognize the book... that is all I see.
Topic archived. No new replies allowed.