summaryrefslogtreecommitdiff
path: root/659/CH2
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /659/CH2
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/CH2')
-rwxr-xr-x659/CH2/EX2.1/exm2_1.sce12
-rwxr-xr-x659/CH2/EX2.1/exm2_1_output.PNGbin0 -> 7302 bytes
-rwxr-xr-x659/CH2/EX2.1cs/Casestudy2_1.sce13
-rwxr-xr-x659/CH2/EX2.1cs/Casestudy2_1_output.PNGbin0 -> 11654 bytes
-rwxr-xr-x659/CH2/EX2.2/exm2_2.sce19
-rwxr-xr-x659/CH2/EX2.2/exm2_2_output.PNGbin0 -> 9118 bytes
-rwxr-xr-x659/CH2/EX2.2cs/Casestudy2_2.sce12
-rwxr-xr-x659/CH2/EX2.2cs/Casestudy2_2_output.PNGbin0 -> 12843 bytes
-rwxr-xr-x659/CH2/EX2.3/exm2_3.sce9
-rwxr-xr-x659/CH2/EX2.3/exm2_3_output.PNGbin0 -> 13420 bytes
-rwxr-xr-x659/CH2/EX2.4/exm2_4.sce13
-rwxr-xr-x659/CH2/EX2.4/exm2_4_output.PNGbin0 -> 24592 bytes
12 files changed, 78 insertions, 0 deletions
diff --git a/659/CH2/EX2.1/exm2_1.sce b/659/CH2/EX2.1/exm2_1.sce
new file mode 100755
index 000000000..18b940afd
--- /dev/null
+++ b/659/CH2/EX2.1/exm2_1.sce
@@ -0,0 +1,12 @@
+// Example 2.1
+// Representation of integer constants on a 16-bit computer.
+
+disp("Integer values");
+//Integer values larger than 32767 are not stored properly on 16-bit machine
+printf("%d %d %d \n",int16(32767),int16(32767+1),int16(32767+10));
+
+disp("Long integer values");
+//To store long integers properly, use int32 integer type
+printf("%ld %ld %ld \n",int32(32767),int32(32767+1),int32(32767+10));
+//The same result as from above statement can be achieved directly from below commented statement
+//printf("%ld %ld %ld\n",32767,32767+1,32767+10); \ No newline at end of file
diff --git a/659/CH2/EX2.1/exm2_1_output.PNG b/659/CH2/EX2.1/exm2_1_output.PNG
new file mode 100755
index 000000000..a9414c6ed
--- /dev/null
+++ b/659/CH2/EX2.1/exm2_1_output.PNG
Binary files differ
diff --git a/659/CH2/EX2.1cs/Casestudy2_1.sce b/659/CH2/EX2.1cs/Casestudy2_1.sce
new file mode 100755
index 000000000..b3b9fbbfc
--- /dev/null
+++ b/659/CH2/EX2.1cs/Casestudy2_1.sce
@@ -0,0 +1,13 @@
+// Case Study:-Chapter 2 Page No.-47
+// 1.Calculation of Average of numbers
+
+N=10;sum1=0;count=0; //Initialization of variables
+printf(" Enter ten numbers");
+while(count<N)
+ number=scanf("%f"); //Reading number(using scanf() function)
+ sum1=sum1+number;
+ count=count+1;
+ end
+ average=sum1/N; //Avarage is calculated
+printf(" N = %d Sum1 = %f",N,sum1 );
+printf(" Average = %f",average );
diff --git a/659/CH2/EX2.1cs/Casestudy2_1_output.PNG b/659/CH2/EX2.1cs/Casestudy2_1_output.PNG
new file mode 100755
index 000000000..c41f774ef
--- /dev/null
+++ b/659/CH2/EX2.1cs/Casestudy2_1_output.PNG
Binary files differ
diff --git a/659/CH2/EX2.2/exm2_2.sce b/659/CH2/EX2.2/exm2_2.sce
new file mode 100755
index 000000000..5a6289afc
--- /dev/null
+++ b/659/CH2/EX2.2/exm2_2.sce
@@ -0,0 +1,19 @@
+// Example 2.2
+// Program shows typical declarations,assignments and values stored in various types of variables.
+
+//Declarations and Assignments
+m=int16(54321);
+n=int32(1234567890);
+k=uint16(54321);
+//Assignments
+x=1.234567890000; //Bydefault type is double in scilab
+y=9.87654321; //----------------------------------
+p=1.0;q=1.0;
+//Printing
+printf(" m=%d\n",m)
+printf(" n=%ld\n",n)
+printf(" x=%.12f\n",x)
+printf(" x=%f\n",x)
+printf(" y=%.12f\n",y)
+printf(" y=%f\n",y)
+printf(" k=%u p=%f q=%.12f\n",k,p,q)
diff --git a/659/CH2/EX2.2/exm2_2_output.PNG b/659/CH2/EX2.2/exm2_2_output.PNG
new file mode 100755
index 000000000..fb7199230
--- /dev/null
+++ b/659/CH2/EX2.2/exm2_2_output.PNG
Binary files differ
diff --git a/659/CH2/EX2.2cs/Casestudy2_2.sce b/659/CH2/EX2.2cs/Casestudy2_2.sce
new file mode 100755
index 000000000..32fd568c2
--- /dev/null
+++ b/659/CH2/EX2.2cs/Casestudy2_2.sce
@@ -0,0 +1,12 @@
+// Case Study:-Chapter 2 Page no.-48
+// 2.Solution of temprature in Farenheit and Celsius
+F_LOW=0;
+F_MAX=250;
+STEP=25;
+fahrenheit=F_LOW; //Initialization
+printf("Fahrenheit Celsius\n\n");
+while(fahrenheit < = F_MAX)
+ celsius=(fahrenheit-32.0)/1.8; //conversion from Farenheit to Celsius
+ printf("%6.2f %7.2f\n",fahrenheit,celsius);
+ fahrenheit=fahrenheit+STEP;
+ end \ No newline at end of file
diff --git a/659/CH2/EX2.2cs/Casestudy2_2_output.PNG b/659/CH2/EX2.2cs/Casestudy2_2_output.PNG
new file mode 100755
index 000000000..cf8db7e7a
--- /dev/null
+++ b/659/CH2/EX2.2cs/Casestudy2_2_output.PNG
Binary files differ
diff --git a/659/CH2/EX2.3/exm2_3.sce b/659/CH2/EX2.3/exm2_3.sce
new file mode 100755
index 000000000..bac1d9631
--- /dev/null
+++ b/659/CH2/EX2.3/exm2_3.sce
@@ -0,0 +1,9 @@
+// Example 2.3
+// The program illustrate the use of scanf() function
+disp("Enter an interger number:");
+number=scanf("%d"); //Read from keyboard
+if(number<100) then
+ disp("Your number is smaller than 100");
+else
+ disp("Your number contain more than two digits");
+end \ No newline at end of file
diff --git a/659/CH2/EX2.3/exm2_3_output.PNG b/659/CH2/EX2.3/exm2_3_output.PNG
new file mode 100755
index 000000000..946cbfc58
--- /dev/null
+++ b/659/CH2/EX2.3/exm2_3_output.PNG
Binary files differ
diff --git a/659/CH2/EX2.4/exm2_4.sce b/659/CH2/EX2.4/exm2_4.sce
new file mode 100755
index 000000000..3830f8d2c
--- /dev/null
+++ b/659/CH2/EX2.4/exm2_4.sce
@@ -0,0 +1,13 @@
+// Example 2.4
+// Sample program 3(exm1.5) discussed in chapter 1 can be convered in to a more flexible intractive program using scanf() function
+disp("Enter in single line separted by space");
+disp("Input amount,interest rate, and period");
+[amount,inrate,period]=scanf("%f %f %d"); //use of scanf()
+year=1;
+//Computation using while loop
+while(year<=period)
+ value=amount+inrate*amount;
+ printf("%2d Rs %8.2f\n",year,value)
+ year=year+1;
+ amount=value;
+end
diff --git a/659/CH2/EX2.4/exm2_4_output.PNG b/659/CH2/EX2.4/exm2_4_output.PNG
new file mode 100755
index 000000000..d4a5fb8c4
--- /dev/null
+++ b/659/CH2/EX2.4/exm2_4_output.PNG
Binary files differ