summaryrefslogtreecommitdiff
path: root/659/CH5/EX5.1cs/Casestudy1.sce
blob: a9184f7163048977faba1ec80f9eb13289029ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//                Case Study:-Chapter 5, Page No:139
//                 1.Range of numbers

sum1=0;
count=0;
f=0;value=1;
printf("Enter numbers[press enter after each number]:\n input a NEGATIVE number to end\n");
while(value)
    [value]=scanf("%f");  //Read data
    if(value<0) then
        break;
    end
    count=count+1;
    //Calculating height and lowest value
    if(count==1) then
        high=value;
        low=value;
     elseif(value>high) then
         high=value;
     elseif(value<low) then
         low=value;
     end
     //Calculate sum
     sum1=sum1+value; 
end
average=sum1/count;     //Average cost
range1=high-low;        //Range of values
//Print the results
printf("Total values: %d\n",count);
printf("Highest-values: %f\nLowest-value: %f\n",high,low);
printf("Range: %f\n Avarage: %f\n",range1,average);