summaryrefslogtreecommitdiff
path: root/659/CH9/EX1.cs
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /659/CH9/EX1.cs
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '659/CH9/EX1.cs')
-rwxr-xr-x659/CH9/EX1.cs/Casestudy1.sci40
-rwxr-xr-x659/CH9/EX1.cs/Casestudy1_output.PNGbin0 -> 17389 bytes
2 files changed, 40 insertions, 0 deletions
diff --git a/659/CH9/EX1.cs/Casestudy1.sci b/659/CH9/EX1.cs/Casestudy1.sci
new file mode 100755
index 000000000..60baca116
--- /dev/null
+++ b/659/CH9/EX1.cs/Casestudy1.sci
@@ -0,0 +1,40 @@
+// Case Study:Chapter-9[page no:310]
+// 1.Calculation of Area under a Curve
+funcprot(0);
+ //global variables
+ global start_point
+ global end_point;
+ global total_area;
+ global numtraps;
+function[]=input1()
+ global start_point;
+ global end_point;
+ global total_area;
+ global numtraps;
+ total_area=0;
+ start_point=input("Enter lower limit:");
+ end_point=input("Enter upper limit:");
+ numtraps=input("Enter number of trapezoids:");
+endfunction
+function[total_area]=find_area(a,b,n)
+ global total_area;
+ base=(b-1)/n; //base is local variable
+ lower=a; //lower is local variable
+ for lower=a:(lower+base):(b-base)
+ h1=function_x(lower);
+ h2=function_x(lower+base);
+ total_area=total_area+trap_area(h1,h2,base); //total area is calculated
+ end
+endfunction
+function[area]=trap_area(height_1,height_2,base)
+ area =0.5*(height_1+height_2)*base; //area is local variable
+endfunction
+function[x] =function_x(x)
+ x=(x^2)+1;
+endfunction
+
+//calling functions
+disp("AREA UNDER CURVE");
+input1(); //calling input1() function
+total_area=find_area(start_point,end_point,numtraps);//calling find_area() function
+printf("TOTAL AREA = %f",total_area); \ No newline at end of file
diff --git a/659/CH9/EX1.cs/Casestudy1_output.PNG b/659/CH9/EX1.cs/Casestudy1_output.PNG
new file mode 100755
index 000000000..e864fa662
--- /dev/null
+++ b/659/CH9/EX1.cs/Casestudy1_output.PNG
Binary files differ