You are on page 1of 9

Lab Task 09_48533

Question no 01
#include <iostream>

using namespace std;

struct Book {

char book_name[100],title[100];

int price,pages,edition;

};

int main() {

Book b;

cout << "Enter title of book\n";

cin.getline(b.title, 100);

cout << "Enter book price\n";

cin >> b.price;

cout << "Enter number of pages\n";

cin >> b.pages;

cout << "Enter edition\n";

cin >> b.edition;


cout << "Enter name of book\n";

cin.getline(b.book_name, 100);

// Printing Book details

cout << "\n*** Book Details ***" << endl;

cout << "Book name : " << b.book_name << endl;

cout << "Price : " << b.price << endl;

cout << "Pages : " << b.pages<<endl;

cout << "Title : " << b.title<<endl;

cout << "Edition : " << b.edition<<endl;

return 0;

OUTPUT
Enter title of book

urdu

Enter book price

235

Enter number of pages

201

Enter edition

02
Enter name of book

*** Book Details ***

Book name :

Price : 235

Pages : 201

Title : urdu

Edition : 2

--------------------------------

Process exited after 50.69 seconds with return value 0

Press any key to continue . . .

Question 02
#include <iostream>

using namespace std;

struct student

char name[50];

int roll;

float marks,avg_marks;
};

int main()

student s;

cout << "Enter information," << endl;

cout << "Enter name: ";

cin >> s.name;

cout << "Enter roll number: ";

cin >> s.roll;

cout << "Enter marks: ";

cin >> s.marks;

cout << "Enter avarage marks: ";

cin >> s.avg_marks;

cout << "\nDisplaying Information," << endl;

cout << "Name: " << s.name << endl;

cout << "Roll: " << s.roll << endl;

cout << "Marks: " << s.marks << endl;

cout << "Avarage marks: " << s. avg_marks << endl;

return 0;

OUTPUT
Enter information,

Enter name: abdullah

Enter roll number: 4533

Enter marks: 45

Enter avarage marks: 34

Displaying Information,

Name: abdullah

Roll: 4533

Marks: 45

Avarage marks: 34

--------------------------------

Process exited after 16.46 seconds with return value 0

Press any key to continue . . .

Question 03
#include<iostream>

#include<conio.h>

using namespace std;

struct Book
{

int b_id;

char b_name[30];

int price;

};

struct Order

{int i;

int order_id;

Book b[100];

};

int main()

Order c;

cout<<"enter number of books :";

int n;

cin>>n;

cout<<"Enter your Order Id: ";

cin>>c.order_id;

cout<<"Enter details of five books: \n";

for(int i=0;i<n;i++)

{
cout<<"\nEnter Book Id: ";

cin>>c.b[i].b_id;

cout<<"Enter Book Name: ";

cin>>c.b[i].b_name;

cout<< " Enter Price of the Book: ";

cin>>c.b[i].price;

cout<<"\n Order details is as follows: "<<endl;

cout<<" Order Id: "<<c.order_id<<endl;

cout<<" Book Id\t Book Name \t Price "<<endl;

for(int i=0;i<n;i++)

cout<<c.b[i].b_id<<"\t\t"<<c.b[i].b_name<<"\t\t"<<c.b[i].price<<endl;

int i ;

int x=0;

for(int i=0;i<n;i++)

if(c.b[0].price<c.b[i].price)

x=i;

cout<<"most costly book detail is :\n";

cout<<c.b[x].b_id<<"\t\t"<<c.b[x].b_name<<"\t\t"<<c.b[x].price<<endl;

}
Output
enter number of books :2

Enter your Order Id: 3

Enter details of five books:

Enter Book Id:

23

Enter Book Name: cvs

Enter Price of the Book: 34

Enter Book Id: 34

Enter Book Name: vd

Enter Price of the Book: 34

Order details is as follows:

Order Id: 3

Book Id Book Name Price

23 cvs 34

34 vd 34

most costly book detail is :

23 cvs 34
--------------------------------

Process exited after 21.65 seconds with return value 0

Press any key to continue . . .

You might also like