Professional Documents
Culture Documents
e x e c u t i v e t h e p r o g r a m f i l e ( . P R G ) , t h e c o m m
DO TEST D O
S T U D E N T NOTE, * && The asterisk character (*)is used to insert comment lines. This can be used to display the name of the command file or to explain command files with descriptive comments about the purpose of following command lines. *the program of finding the biggest number* NOTE The Note command does precisely the same thing as the asterisk
(*) charact er and can be used intercha ngeably . To continu e to comme nt on the followi ng line, semicol on (;) should be used at the end of first comme nt line. NOTE T h i s c o m m e n t l i n e i s f o r ;
I n f o r m a t i o n p u r p o s e o n l y & & This is another comment designator that can be used to insert comments on the same line as a command. The FoxPro command interpreter ignores the && and following text. Example: Wait && pauses and displays "press any key to continue" PRINT STATEMENT ? The question mark is used to print the message or variables and the question mark with- any message or variables indicate to display a blank line. Example : ? "Name of student"'. Name > ?? expression : The double marks causes text to print on the same line. ??? expression :
The three questions marks direct the contents of the expression directly to a printer without lung it through a printer driver. This is useful because it allows you to use printer codes that not supported by the printer driver. MPLE PROGRAMS To assign any 3 numbers and print the same Clear Store 0 to A.B.C A=5 B= 10 C= 15 ?A ?B ?C Example To assign any 2 numbers and find the sum, product, ratio and difference and print the MB. CLEAR STORE 0 TO Nl, N2, SUM. PRO. DIE RAT STORE 100 TO Nl STORE 50 TO N2 SUM = Nl + N2 PRO = Nl * N2 DIF = N1-N2 RAT = N1-N2 ?"SUM OF TWO NUMBERS = **, SUM TTRODUCT OF TWO NUMBERS = ". PRO ? -DIFFERENCE OF TWO NUMBERS = ". DIF ?RATIO OF TWO NUMBERS = ", RAT
>
ACCEPT This command is used to accept the character type data memory variable from the user through the Keyboard after executive the program. SYNTAX ACCEPT < "expression'^ TO <variable> Example ACCEPT "Enter students name" To name INPUT This command is used to input a numeric memory variable from the user through the Keyboard after executive the program. INPUT "Enter the marks" TO mark INPUT "Enter the Sales amount " TO sale_amount Example
To Input any 2 numbers and find the sum, product, ratio and difference and print the results. CLEAR STORE 0 TO Nl, N2, SUM, PRO, DIF, RAT INPUT "ENTER FIRST NUMBER = " TO Nl INPUT "ENTER SECOND NUMBER = " TO N2 SUM = Nl + N2 PRO = Nl * N2 DIF = N1-N2 RAT = N1-N2 ?"SUM OF TWO NUMBERS = ", SUM ?"PRODUCT OF TWO NUMBERS = ", PRO ? "DIFFERENCE OF TWO NUMBERS = ", DIF T'RATIO OF TWO NUMBERS = ", RAT
> IF - ENDIF
This set of commands form a complete branching statement SYNTAX IF <expression> (command lines) ENDIF example IF A>B ? "A is Big", A ENDIF Ixample To input any 2 numbers and find the biggest number * STORING THE VALUES * STORE 0 TO A,B * INPUTTING* INPUT "ENTER THE VALUE OF A" TO A INPUT "ENTER THE VALUE OF B" TO B * CHECKING * IF A>B ? "A IS BIG" ENDIF IF B>A ? "B IS BIG" ENDIF
To input any two numbers and find the smallest one STORE 0 TO A, B INPUT "ENTER THE VALUE OF A" TO A INPUT "ENTER THE VALUE OF B" TO B CHECKING* IF A<B ? "A IS SMALL", A ELSE ? "B IS SMALL ", B ENDIF Example To input any NO. and find whether the given number is positive or negative. * TO FIND INPUTED NUMBER IS + ve OR - ve INPUT "ENTER ANY NUMBER :" TO NUM IFNUM = 0 ?" INPUETD NUMBER IS ZERO" , NUM ELSE IF NUM > 0 ? " NUMBER IS POSITIVE ", NUM ELSE ? " NUMBER IS NEGATIVE ", NUM ENDIF ENDD7