summaryrefslogtreecommitdiff
path: root/1034/CH1/EX1.5/example5.sce
blob: 961cedc699431e47cee1f560a65b11794b1dbea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//     example 1.5
//   ADT(Abstract Data type) defination of natural number.
 function[]=ADT(x)
     printf("ADT natural no. is ");
 printf("\nOBJECTS: an ordered subrange of the integers starting at zero and ");
     printf("ending at the maximun integer (INT_MAX) on the computer");
    INT_MAX=32767;
    if x==0                 //NaturalNumberZero()
        printf("\n",0);
        end
        if x==INT_MAX then     //NaturalNumberSuccessor(x)
            printf("\nans. is=%d",x);
        else 
            printf("\nans. is=%d",x+1);
        end 
    endfunction
    //callin routine
    x=56
    y=ADT(x);