100% found this document useful (2 votes)
5K views10 pages

Foxpro Program

This document contains 29 programs written in a programming language to perform various mathematical and logical calculations. The programs include calculating squares, cubes, simple and compound interest, areas of shapes, factorials, sorting numbers, generating sequences, and payroll/commission calculations. The programs demonstrate the use of variables, conditional statements, loops, inputs, outputs and other basic programming constructs.

Uploaded by

Subramanya Dg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
5K views10 pages

Foxpro Program

This document contains 29 programs written in a programming language to perform various mathematical and logical calculations. The programs include calculating squares, cubes, simple and compound interest, areas of shapes, factorials, sorting numbers, generating sequences, and payroll/commission calculations. The programs demonstrate the use of variables, conditional statements, loops, inputs, outputs and other basic programming constructs.

Uploaded by

Subramanya Dg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

SQUARE OF A GIVEN NUMBER


SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR N " TO N
S=(N*N)
? "SQUARE OF A GIVEN NUMBER ",S
WAIT
SET TALK ON
SET STAT ON
2. CUBE OF A GIVEN NUMBER
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR N " TO N
C=(N*N*N)
? "CUBE OF A GIVEN NUMBER ",C
WAIT
SET TALK ON
SET STAT ON
3. SIMPLE INTEREST AND AMOUNT
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR PRINCIPLE " TO P
INPUT "ENTER A VALUE FOR RATE " TO R
INPUT "ENTER A VALUE FOR TERM " TO T
SI=(P*R*T)/100
AMT=P+SI
? "SIMPLE INTEREST IS ",SI
? "AMOUNT IS ", AMT
WAIT
SET TALK ON
SET STAT ON
4. CALCULATION OF COMPOUND INTEREST
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR PRINCIPLE AMOUNT " TO P
INPUT "ENTER A VALUE FOR RATE " TO R
INPUT "ENTER A VALUE FOR PERIOD " TO T
CI=P*(1+R/100)^T - P
AMT = CI + P
? "TOTAL AMOUNT IS ", AMT
? "COMPOUND INTEREST ",CI
WAIT
SET TALK ON
SET STAT ON
1

5. CALCULATION OF ANNUITY
SET TALK OFF
SET STAT OFF
CLEA
INPUT "ENTER A VALUE FOR INSTALMENT " TO A
INPUT "ENTER A VALUE FOR RATE " TO R
INPUT "ENTER A VALUE FOR NUMBER OF YEARS " TO N
R1 = R/100
FA= (A/R1*(1+R)*N-1)
?"FUTURE ANNUITY IS --------------->", FA
WAIT
SET TALK ON
SET STAT ON
6. CALCULATION OF AREA OF A CIRCLE
SET TALK OFF
SET STAT OFF
CLEA
INPUT "ENTER THE VALUE FOR RADIUS " TO R
P=3.142
A=P*R^2
C=2*P*R
?"AREA OF A CIRCLE ", A
?CIRCUMFERENCE IS , C
WAIT
SET TALK ON
SET STAT ON
7.

*AREA OF A TRIANGLE*
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR A-------" TO A
INPUT "ENTER A VALUE FOR B-------" TO B
INPUT "ENTER A VALUE FOR C-------" TO C
S=(A+B+C)/2
AREA=SQRT(S-A)*(S-B)*(S-C)
?"AREA OF A TRIANGLE IS-------",AREA
WAIT
SET TALK ON
SET STAT ON

8. SUM OF NATURAL NUMBERS


SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR N " TO N
SN = N*(N+1)/2
? "SUM OF NATURAL NUMBERS-->", SN
WAIT
SET TALK ON
SET STAT ON
9. **ELIGIBILITY TO VOTE IN AN ELECTION**
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER THE AGE OF A STUDENT----" TO A
IF A>=18
?"ELIGIBLE TO VOTE"
ELSE
?"NOT ELIGIBLE TO VOTE"
ENDIF
WAIT
SET TALK ON
SET STAT ON
10.*ELIGIBLITY TO VTU EXAM*
SET TALK OFF
SET STAT OFF
CLEA
INPUT "ENTER THE AGE OF A STUDENT----" TO A
IF A>=20
?"ELIGIBLE TO VTU EXAM"
ELSE
?"NOT ELIGIBLE TO VTU EXAM"
ENDIF
WAIT
SET TALK ON
SET STAT ON
11.

**simple mathematical calculation**


set talk off
set stat off
clear
input "enter a value for a-->"to a
input "enter a value for b-->"to b
? "addition of two numbers-->",a+b
? "subtraction of two numbers-->",a-b
? "multiplication of two numbers-->",a*b
? "division of two numbers-->",a/b
wait
set talk on
set stat on
3

12.

**biggest among two numbers**


set talk off
set stat off
clear
input "enter a value for a-->"to a
input "enter a value for b-->"to b
if a>b
? "a is big"
else
? "b is big"
endif
wait
set talk on
set stat on

13.

**biggest among three numbers**


set talk off
set stat off
clear
input "enter the value for a-->"to a
input "enter the value for b-->"to b
input "enter the value for c-->"to c
if a>b and a>c
? "a is big"
else
if b>a and b>c
? "b is big"
else
? "c is big"
endif
endif
wait
set talk on
set stat on

14.

**smallest among two numbers**


set talk off
set stat off
clear
input "enter a value for a-->"to a
input "enter a value for b-->"to b
if a<b
? "a is small"
else
? "b is small"
endif
wait
set talk on
set stat on
4

15.

**smallest among three numbers**


set talk off
set stat off
clear
input "enter a value for a-->"to a
input "enter a value for b-->"to b
input "enter a value for c-->"to c
if a<b and a<c
? "a is small"
else
if b<a and b<c
? "b is small"
else
? "c is small"
endif
endif
wait
set talk on
set stat on

16.

**biggest among four numbers**


set talk off
set stat off
clear
input "enter the value for first number-->"to a
input "enter the value for second number-->"to b
input "enter the value for third number-->"to c
input "enter the value for fourth number-->"to d
if a>b and a>c and a>d
? "a is big"
else
if b>a and b>c and b>d
? "b is big"
else
if c>a and c>b and c>d
? "c is big"
else
? "d is big"
endif
endif
endif
wait
set talk on
set stat on

17. **smallest among four numbers**


set talk off
set stat off
clear
input "enter the value for first number-->"to a
input "enter the value for second number-->"to b
input "enter the value for third number-->"to c
input "enter the value for fourth number-->"to d
if a<b and a<c and a<d
? "a is small"
else
if b<a and b<c and b<d
? "b is small"
else
if c<a and c<b and c<d
? "c is small"
else
? "d is small"
endif
endif
endif
wait
set talk on
set stat on
18. **generation of natural numbers**
set talk off
set stat off
clear
input "enter a value for end number " to a
FOR I = 1 TO N
?I
endfor
wait
set talk on
set stat on
19.

*GENERATION OF ODD NUMBER FROM 1 TO 25 AND THEIR SUM**


SET TALK OFF
SET STAT OFF
CLEAR
S=0
FOR I = 1 TO 25 STEP 2
?I
S=S+I
ENDFROR
? "SUM OF ODD NUMBERS-->",S
WAIT
SET TALK ON
SET STAT ON
6

20. **GENERATE EVEN NUMBERS FROM 20 TO 100 AND THEIR SUM**


SET TALK OFF
SET STAT OFF
CLEAR
S=0
FOR I = 20 TO 100 STEP 2
?I
S=S+I
ENDFOR
? "SUM OF EVEN NUMBERS ARE-->",S
WAIT
SET TALK ON
SET STAT ON
21.

**GENERATION OF REVERSE NATURAL NUMBERS from 100 to 1**


SET TALK OFF
SET STAT OFF
CLEAR
For I = 100 to 1 Step -1
?I
Endfor
WAIT
SET TALK ON
SET STAT ON

22.

**GENERATION OF REVERSE ODD NUMBERS from 99 to 25**


SET TALK OFF
SET STAT OFF
CLEAR
For I = 99 to 25 Step -2
?I
Endfor
WAIT
SET TALK ON
SET STAT ON

23.

**REVERSE EVEN NATURAL NUMBERS FROM 100 TO 2**


SET TALK OFF
SET STAT OFF
CLEAR
For I = 100 to 2 Step -2
?I
Endfor
WAIT
SET TALK ON
SET STAT ON

24.*TO FIND FACTORIAL OF GIVEN NUMBER


SET TALK OFF
SET STAT OFF
CLEA
F=1
FOR I = 1 TO N
F=F*I
ENDFOR
?"FACTORIAL ", F
WAIT
SET TALK ON
SET STAT ON
25. MULTIPLICATION TABLES**
SET TALK OFF
SET STAT OFF
CLEAR
INPUT "ENTER A VALUE FOR N " TO N
FOR I = 1 TO 10
? N, " x ", P , "=", N * P
ENDFOR
WAIT
26. *BIGGEST AMONG TEN NO*
SET TALK OFF
SET STAT OFF
CLEAR
Big = -1000
For I = 1 to 10
INPUT " ENTER THE Number " TO N
IF N >Big
Big = N
ENDIF
ENDFOR
?"BIGGEST AMONG NOS----", Big
WAIT
SET TALK ON
SET STAT ON

27.

*PROGRAM TO CALCULATE WAGES*


SET TALK OFF
SET STAT OFF
CLEAR
ACCEPT "ENTER THE NAME OF EMPLOYEE " TO E
INPUT "ENTER EMPLOYEE CODE NO " TO C
INPUT "HOURS WORKED " TO H
INPUT "ENTER RATE PER HOUR WORKED----" TO R
W=R*H
?"EMPLOYEE NAME----",E
?"EMPLOYEE CODE NO----",C
?"HOURS WORKED----",HW
?"RATE/HOUR WORKED----",R
?"TOTAL WAGES EARNED----",W
WAIT
SET TALK ON
SET STAT ON

28.

*SALARY STATEMENT*
SET TALK OFF
SET STAT OFF
CLEAR
ACCEPT "ENTER THE EMPLOYEE NAME------" TO N
INPUT "ENTER EMPLOYEE CODE NO-------" TO C
INPUT "ENTER THE BASIC SALARY-----" TO BS
HRA=BS*5/100
CCA=BS*2/100
DA=BS*150/100
GS=BS+HRA+CCA+DA
PF=BS*3/100
IT=GS*4/100
DED=PF+IT
NS=GS-DED
?"EMPLOYEE NAME----",N
? HRA IS , HRA
? CCA IS, CCA
? DA IS , DA
? PF IS , PF
? IT IS , IT
? GROSS SALARY , GS
? DEDUXTION IS , DED
?"NET SALARY IS ",NS
WAIT
SET TALK ON
SET STAT ON
9

29.

*COMMISSION EARNED BY SALESMEN**


SET TALK OFF
SET STAT OFF
CLEAR
ACCEPT "ENTER SALESMAN'S NAME ------" TO SN
INPUT "ENTER SALESMAN'S NO- ------" TO N
INPUT "ENTER SALES DONE -------" TO SD
IF SD >= 25000 AND SD < 50000
COMM=SD*5/100
ELSE
IF SD >=50000 AND SD < 75000
COMM=SD*8/100
ELSE
COMM=SD*10/100
ENDIF
ENDIF
ENDIF
? "SALESMAN NAME------------", SN
? "SALESMAN NO--------------", N
? "SALES DONE---------------", SD
? "COMMISSION EARNED--------", COMM
WAIT
SET TALK ON
SET STAT ON

10

You might also like