diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /659/CH3 | |
download | Scilab-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/CH3')
-rwxr-xr-x | 659/CH3/EX3.1/exm3_1.sce | 8 | ||||
-rwxr-xr-x | 659/CH3/EX3.1/exm3_1_output.PNG | bin | 0 -> 7753 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.1cs/Casestudy3_1.sce | 16 | ||||
-rwxr-xr-x | 659/CH3/EX3.1cs/Casestudy3_1_output.PNG | bin | 0 -> 9227 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.2/exm3_2.sce | 9 | ||||
-rwxr-xr-x | 659/CH3/EX3.2/exm3_2_output.PNG | bin | 0 -> 5256 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.2cs/Casestudy3_2.sce | 19 | ||||
-rwxr-xr-x | 659/CH3/EX3.2cs/Casestudy3_2_output.PNG | bin | 0 -> 16184 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.3/exm3_3.sce | 22 | ||||
-rwxr-xr-x | 659/CH3/EX3.3/exm3_3_output.PNG | bin | 0 -> 7569 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.4/exm3_4.sce | 16 | ||||
-rwxr-xr-x | 659/CH3/EX3.4/exm3_4_output.PNG | bin | 0 -> 4705 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.5/exm3_5.sce | 13 | ||||
-rwxr-xr-x | 659/CH3/EX3.5/exm3_5_output.PNG | bin | 0 -> 4854 bytes | |||
-rwxr-xr-x | 659/CH3/EX3.6/exm3_6.sce | 8 | ||||
-rwxr-xr-x | 659/CH3/EX3.6/exm3_6_output.PNG | bin | 0 -> 9240 bytes |
16 files changed, 111 insertions, 0 deletions
diff --git a/659/CH3/EX3.1/exm3_1.sce b/659/CH3/EX3.1/exm3_1.sce new file mode 100755 index 000000000..8ffe52210 --- /dev/null +++ b/659/CH3/EX3.1/exm3_1.sce @@ -0,0 +1,8 @@ +// Example 3.1
+//The program shows the use of integer arithmetic to convert a given number-
+//of days into months and days
+
+days=input('Enter days:');
+months=int16(days/30); //Compute for months
+days =int16(pmodulo(days,30)); //compute for days
+disp(days,"Days =",months,"Months =");
\ No newline at end of file diff --git a/659/CH3/EX3.1/exm3_1_output.PNG b/659/CH3/EX3.1/exm3_1_output.PNG Binary files differnew file mode 100755 index 000000000..c7965057c --- /dev/null +++ b/659/CH3/EX3.1/exm3_1_output.PNG diff --git a/659/CH3/EX3.1cs/Casestudy3_1.sce b/659/CH3/EX3.1cs/Casestudy3_1.sce new file mode 100755 index 000000000..85a1bbfb4 --- /dev/null +++ b/659/CH3/EX3.1cs/Casestudy3_1.sce @@ -0,0 +1,16 @@ +// Case Study:-Chapter 3,Page No:76
+// 1.Salesman's Salary
+
+
+BASE_SALARY=1500.00; //Minimum base salary
+BONUS_RATE=200.00; //Bonus for every computer sold
+COMMISSION=0.02; //Commission on total monthly sales
+printf("Input number sold and price\n[Enter in single line separated by space]");
+[quantity,price] = scanf("%d %f"); //Input quantity and price
+//Computation for bonus,commission and gross_salary of a salesman
+bonus = BONUS_RATE*quantity;
+commission = COMMISSION*quantity*price;
+gross_salary =BASE_SALARY + bonus + commission;
+printf("Bonus = %6.2f\n", bonus);
+printf("Commission = %6.2f\n", commission);
+printf("Gross salary = %6.2f\n", gross_salary);
diff --git a/659/CH3/EX3.1cs/Casestudy3_1_output.PNG b/659/CH3/EX3.1cs/Casestudy3_1_output.PNG Binary files differnew file mode 100755 index 000000000..af6bfd20f --- /dev/null +++ b/659/CH3/EX3.1cs/Casestudy3_1_output.PNG diff --git a/659/CH3/EX3.2/exm3_2.sce b/659/CH3/EX3.2/exm3_2.sce new file mode 100755 index 000000000..24a96e1e4 --- /dev/null +++ b/659/CH3/EX3.2/exm3_2.sce @@ -0,0 +1,9 @@ +// Example 3.2
+//Program to print a sequence of squares of numbers.
+
+N=100;A=2;
+a=A;
+while(a<N)
+ disp(a); //Prints square of number
+ a=a^2; //compute square of number
+end
\ No newline at end of file diff --git a/659/CH3/EX3.2/exm3_2_output.PNG b/659/CH3/EX3.2/exm3_2_output.PNG Binary files differnew file mode 100755 index 000000000..ff3c6c469 --- /dev/null +++ b/659/CH3/EX3.2/exm3_2_output.PNG diff --git a/659/CH3/EX3.2cs/Casestudy3_2.sce b/659/CH3/EX3.2cs/Casestudy3_2.sce new file mode 100755 index 000000000..f5fcac524 --- /dev/null +++ b/659/CH3/EX3.2cs/Casestudy3_2.sce @@ -0,0 +1,19 @@ +// Case Study:-Chapter 3,Page No:77
+// 2.Solution of the Quadratic equation
+
+
+printf("Input values of a, b, and c \n");
+a=input("a =");
+b=input("b =");
+c=input("c =");
+discriminant = b^2-4*a*c;
+if(discriminant<0)
+ printf("\n\nROOTS ARE IMAGINARY\n");
+else
+ //Computes root1 and root2
+ root1 = (-b + sqrt(discriminant))/(2.0*a);
+ root2 = (-b - sqrt(discriminant))/(2.0*a);
+ printf("\n\nRoot1 = %5.2f\n\nRoot2 = %5.2f\n",root1,root2 );
+end
+
+
diff --git a/659/CH3/EX3.2cs/Casestudy3_2_output.PNG b/659/CH3/EX3.2cs/Casestudy3_2_output.PNG Binary files differnew file mode 100755 index 000000000..e4cefd126 --- /dev/null +++ b/659/CH3/EX3.2cs/Casestudy3_2_output.PNG diff --git a/659/CH3/EX3.3/exm3_3.sce b/659/CH3/EX3.3/exm3_3.sce new file mode 100755 index 000000000..1ccb2ccb7 --- /dev/null +++ b/659/CH3/EX3.3/exm3_3.sce @@ -0,0 +1,22 @@ +// Example 3.3
+//The program employs diffrent kind of operators. The results of their evaluation are also shown for comparison
+
+//Increment(i.e. ++)/Decrement(--) operators are unavailable in Scilab
+a=int16(15);
+b=int16(10);
+a=a+1; // Replacement for ++a
+c=a-b;
+printf("a = %d b = %d c = %d\n",a,b,c);
+b=b+1; // Replacement for b++
+d=b+a;
+printf("a = %d b = %d d = %d\n",a,b,d);
+printf("a/b = %d\n",a/b); //Division operator
+printf("pmodulo(a,b) = %d\n",pmodulo(a,b)); //Modulus operatior
+printf("a*b = %d\n",a*b); //Multiplication
+//In scilab ther is no conditional operator(?:),hence 'if' can be used in place of ?:
+if(c>d) then
+ disp(1);
+end
+if(c<d) then
+ disp(0);
+end
\ No newline at end of file diff --git a/659/CH3/EX3.3/exm3_3_output.PNG b/659/CH3/EX3.3/exm3_3_output.PNG Binary files differnew file mode 100755 index 000000000..4366325ee --- /dev/null +++ b/659/CH3/EX3.3/exm3_3_output.PNG diff --git a/659/CH3/EX3.4/exm3_4.sce b/659/CH3/EX3.4/exm3_4.sce new file mode 100755 index 000000000..1c339326f --- /dev/null +++ b/659/CH3/EX3.4/exm3_4.sce @@ -0,0 +1,16 @@ +// Example 3.4
+//The program illustrates the use of variables in expressions and their evaluation.
+
+a=9;b=12;c=3;
+//Expressions and their evaluations
+x=a-b/3+c*2-1;
+y=a-b/(3+c*(2-1));
+z=a-(b/(3+c)*2)-1;
+
+printf("x=%f\n",x)
+printf("y=%f\n",y)
+printf("z=%f\n",z)
+// disp can be used..
+//disp(x,"x=")
+//disp(y,"y=")
+//disp(z,"z=")
diff --git a/659/CH3/EX3.4/exm3_4_output.PNG b/659/CH3/EX3.4/exm3_4_output.PNG Binary files differnew file mode 100755 index 000000000..7be257c57 --- /dev/null +++ b/659/CH3/EX3.4/exm3_4_output.PNG diff --git a/659/CH3/EX3.5/exm3_5.sce b/659/CH3/EX3.5/exm3_5.sce new file mode 100755 index 000000000..93136c7b1 --- /dev/null +++ b/659/CH3/EX3.5/exm3_5.sce @@ -0,0 +1,13 @@ +// Example 3.5
+//Output of program shows round-off errors that can occur in computation of floating point numbers
+
+//Sum of n terms of 1/n
+count=1;
+sum1=0;
+n=input("Enter value of n:");
+term=1.0/n;
+while(count<=n)
+ sum1=sum1+term;
+ count=count+1;
+end
+printf("Sum= %f",sum1);
\ No newline at end of file diff --git a/659/CH3/EX3.5/exm3_5_output.PNG b/659/CH3/EX3.5/exm3_5_output.PNG Binary files differnew file mode 100755 index 000000000..c8733efa3 --- /dev/null +++ b/659/CH3/EX3.5/exm3_5_output.PNG diff --git a/659/CH3/EX3.6/exm3_6.sce b/659/CH3/EX3.6/exm3_6.sce new file mode 100755 index 000000000..8fb15d18d --- /dev/null +++ b/659/CH3/EX3.6/exm3_6.sce @@ -0,0 +1,8 @@ +// Example 3.6
+//Program using a cast to evaluate the equation.
+
+sum1=0;
+for n=int8(1:10)
+ sum1=sum1+1/double(n); //conversion from 'int' to 'double' or 'float'
+ printf("%2d %6.4f\n",n,sum1);
+end
\ No newline at end of file diff --git a/659/CH3/EX3.6/exm3_6_output.PNG b/659/CH3/EX3.6/exm3_6_output.PNG Binary files differnew file mode 100755 index 000000000..0cbea2b03 --- /dev/null +++ b/659/CH3/EX3.6/exm3_6_output.PNG |