whats wrong with this code :( can anyone figure it out?plz help me out

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
//Write a program that declares a structure to store Book ID, price and pages of a book. it defines two structure variable and inputs values.
//it displays the record of most costly book.
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
struct book
{
	string id;
	string price;
	string pages;
};
main()
{
	book b[2];
	for(int i=0;i<2;i++)
	{
	 cout<<"enter the book id   ";
	 cin>>b[i].id;
	 cout<<"enter its price   ";
	 cin>>b[i].price;
	 cout<<"enter its number of pages   ";
	 cin>>b[i].pages;
	}
	string priceofbook1=b[0].price;
	 string priceofbook2=b[1].price;
	string temp=0;
	for(int i=0;i<2;i++)
		 {
                       // if(b[0].price<b[1].price)
         if(temp<b[i].price)
         {
                        temp=b[i].price;
                        //cout<<"highest price is"<<b[1].price;
                     //   break; 
         } 
                       //else
         //{
                        //n=b[i].price;
                        //cout<<"highest price is"<<b[0].price; 
         } 
         cout<<"highest price is"<<temp;                                  
		 //}


	 _getch();
	}


	 
Last edited on
line 27: make zero quoted couse all strings must be quoted "0"
:/
Last edited on
thank you so much #konstantin2, i got it
GOD bless you
Topic archived. No new replies allowed.