From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 659/CH10/EX1.cs/Casestudy.sci | 56 +++++++++++++++++++++++++++++++++++ 659/CH10/EX1.cs/Casestudy_output.PNG | Bin 0 -> 41510 bytes 659/CH10/EX10.1/exm10_1.sce | 18 +++++++++++ 659/CH10/EX10.1/exm10_1_output.PNG | Bin 0 -> 7462 bytes 659/CH10/EX10.2/exm10_2.sci | 18 +++++++++++ 659/CH10/EX10.2/exm10_2_output.PNG | Bin 0 -> 5707 bytes 659/CH10/EX10.3/exm10_3.sce | 31 +++++++++++++++++++ 659/CH10/EX10.3/exm10_3_output.PNG | Bin 0 -> 11514 bytes 659/CH10/EX10.4/exm10_4.sce | 33 +++++++++++++++++++++ 659/CH10/EX10.4/exm10_4_output.PNG | Bin 0 -> 11634 bytes 659/CH10/EX10.5/exm10_5.sce | 34 +++++++++++++++++++++ 659/CH10/EX10.5/exm10_5_output.PNG | Bin 0 -> 10444 bytes 12 files changed, 190 insertions(+) create mode 100755 659/CH10/EX1.cs/Casestudy.sci create mode 100755 659/CH10/EX1.cs/Casestudy_output.PNG create mode 100755 659/CH10/EX10.1/exm10_1.sce create mode 100755 659/CH10/EX10.1/exm10_1_output.PNG create mode 100755 659/CH10/EX10.2/exm10_2.sci create mode 100755 659/CH10/EX10.2/exm10_2_output.PNG create mode 100755 659/CH10/EX10.3/exm10_3.sce create mode 100755 659/CH10/EX10.3/exm10_3_output.PNG create mode 100755 659/CH10/EX10.4/exm10_4.sce create mode 100755 659/CH10/EX10.4/exm10_4_output.PNG create mode 100755 659/CH10/EX10.5/exm10_5.sce create mode 100755 659/CH10/EX10.5/exm10_5_output.PNG (limited to '659/CH10') diff --git a/659/CH10/EX1.cs/Casestudy.sci b/659/CH10/EX1.cs/Casestudy.sci new file mode 100755 index 000000000..b7489ba23 --- /dev/null +++ b/659/CH10/EX1.cs/Casestudy.sci @@ -0,0 +1,56 @@ +// Case study: Chapter-10, Page No:341 +// Book Shop Inventory + +funcprot(0); +//Defining functions +function [string1]=get1() + string1=read(%io(1),1,1,'(a)'); +endfunction +function [i] =look_up(table,s1,s2,m) + for i=1:m + x=strcmp(s1,table(i).title); + y=strcmp(s2,table(i).author); + if x==0 & y==0 then + return i; //Book found + end + end + i=-1; //Book not found +endfunction + +//Creates array of structures +book=[struct('author','Ritche','title','C Language','price',45.00,'month','May','year',1977,'publisher','PHI','quantity',10) + struct('author','Kochan','title','Programming in C','price',75.50,'month','July','year',1983,'publisher','Hayden','quantity',5) + struct('author','Balagurusamy','title','BASIC','price',30.00,'month','January','year',1984,'publisher','TMH','quantity',0) + struct('author','Balagurusamy','title','COBOL','price',60.00,'month','December','year',1988,'publisher','Macmillan','quantity',25) + ]; +n=size(book); +no_of_records=n(1); +response=' ', a=1; +while ((response=='Y' | response=='y')|a==1) + //Read data + printf("Enter title and author name as per the list:\n"); + printf("Title: \n"); + title1=get1(); + printf("Author:\n"); + author1=get1(); + //Calling index() function and + //Passing structure book to function look_up() + index=look_up(book,title1,author1,no_of_records); + //If book found then print the book detail otherwise not in list + if index~=-1 & index then //Book found + printf("% s %s",book(index).author, book(index).title); + printf("% .2f %s",book(index).price, book(index).month); + printf("% d %s\n",book(index).year, book(index).publisher); + quantity=input("Enter number of copies :"); + if quantity