0% found this document useful (0 votes)
84 views6 pages

Visual Foxpro Programming

Uploaded by

prasenjitdas1221
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views6 pages

Visual Foxpro Programming

Uploaded by

prasenjitdas1221
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VISUAL FOXPRO PROGRAMMING:

What is Program?

Ans. A program, written in computer language, is the set of instructions to


perform a specific task.

What is Compiler?

Ans. Compiler is system software which can convert user-level language to


machine –level language [i.e. Binary form] as a whole. So, in Visual FoxPro,
Compiler converts the English like code to machine readable code to
execute.
Multiple FoxPro commands cam be stored in a program file and executed
by a single statement.

To Create/Modify A Program File:


Syntax: MODIFY COMMAND Program_filename Example: MODI COMM
Barrackpore

To Execute A Program File:


Syntax: DO Program_filename Example: DO Barrackpore

Steps to create a program:


1) Write the command to create the program file.
2) Type all the statements related to the task
3) Compile the program file form Program Menu  Compile Option
4) After getting the message “0 Compilation Errors” Save and close the program

Program 1.
Write a Program to accept a name and display the name
Set talk off
clear
Name=Space(30)
@ 5, 10 say [Enter the Name: ] get Name
read
@ 7, 10 say [The Name is = ]+Name
return
Program 2.
Write a program accepts a date and add one year with inputted date and display the new date
Set talk off
set century on
clear
DT={}
@ 5, 10 say [Enter the Date: ] get DT PICTURE "99/99/9999"
read
DT=gomonth(DT,12)
@ 7, 10 say [The New Date is=]+DTOC(DT)
return

Program 3.
Write a program to accept Name, Account Number, and Balance Amount
Set talk off
clear
AName=Space(30)
Acc_No=Space(20)
Balance_Amount=0
@ 5, 10 say [Enter the Name : ] get AName style "B"
read
@ 7, 10 say [Enter Account Number : ] get Acc_No picture "AAA99999999" style "B"
read
@ 9, 10 say [Enter the Balance Amount]get Balance_Amount picture “9,99,999" style "B"
read
@ 11, 10 say [Your Name is : ] +AName
@ 13, 10 say [Your Account Number is : ] +Acc_NO
@ 15, 10 say [Your Balance Amount is : ] +str(Balance_Amount)

Program 4.
Write a program to accept two numbers and add, sub, mul, div
Set talk off
clear
First_No=0
Second_No=0
Add=0
Sub=0
Mul=0
Div=0.00
@ 5, 10 Say [Enter the First Number: ] get First_No range 0,100
read
@ 7, 10 Say "Enter the Second Number: " get Second_No range 0,100
read
Add=First_No+Second_No
Sub=First_No-Second_No
Mul=First_No*Second_No
Div=First_No/Second_No
@ 9, 10 Say "The Addition Result is : "+str(Add)
@ 11, 10 Say "The Subtraction Result is : "+str(Sub)
@ 13, 10 Say "The Multiplication Result is : "+str(Mul)
@ 15, 10 Say "The Division Result is : "+str(Div)
Return
Program 5
Write a program to accept a name in Lowercase and display it in Uppercase.

Set talk off


clear
Name=space(30)
UName=Space(30)
@ 5,10 say "Enter any Name in Lower Case : " get Name
Read
UName=Upper(Name)
@ 7,10 say "Your name in Upper case : " + UName
Return
Program 6
Write a program to check the number even or odd
Set talk off
clear
No=0
@5,10 say “Enter any number : “ get No
Read
If mod(No,2)=0
@7,10 say “The Number is Even “
Else
@7,10 say “The Number is Odd “
Endif
Program 7
Write a program to accept any name and show the characters value
Set talk off
clear
Ename=space(10)
length=0
@5,10 say "Enter any Name : " Get Ename
Read
length=Len(Ename)
@10,10 say "The number of characters are : " +str(length)
Program 8
Write a program to accept the Customer ID number, name and consume current and calculate the
amount paid for electricity.
Units consumed Rate Per Unit
First 100 units Rs. 4.50 per unit
Next 200 units Rs. 5 per unit
Next 200 units Rs. 5.70 per unit
Above 500 units Rs. 6.50 per unit
Ans.
Set talk off
clear
ID=0
Ename=space(10)
cbill=0
amt1=0.00
amt2=0.00
@5,10 say "Enter Consumer ID Number : " Get ID
read
@7,10 say "Enter Consumer Name : " Get Ename
Read
@9,10 say "Enter units consumed : " Get cbill
read
if (cbill<=100)
amt1=cbill*4.50
amt2=amt1+100
@11,10 say "Amount to be paid by customer " +str(amt2)
endif
if (cbill<=300)
amt1=(cbill-100)*5
amt2=amt1+100+450
@11,10 say "Amount to be paid by customer " +str(amt2)
endif
if (cbill<=500)
amt1=(cbill-300)*5.70
amt2=amt1+100+450+1000
@11,10 say "Amount to be paid by customer " +str(amt2)
endif
if (cbill>500)
amt1=(cbill-500)*6.50
amt2=amt1+100+450+1000+1140
@11,10 say "Amount to be paid by customer " +str(amt2)
Endif
Program 9
Write a program to accept any number in between 1 to 5 and display the number in words.
Set talk off
Clear
No=0
@5,10 say “Enter any Number : “ get No range 1,5.
Read
Do Case
Case No=1
@7,10 say “ONE”
Case No=2
@7,10 say “TWO”
Case No=3
@7,10 say “THREE”
Case No=4
@7,10 say “FOUR”
Case No=5
@7,10 say “FIVE”
Otherwise
Case No=1
@7,10 say “Invalid Number”
Endcase
Program 10
Write a program to accept three numbers and display the biggest number
Set talk off
Clear
No1=0
No2=0
No3=0
@5,10 say "Enter First Number : " get No1
Read
@7,10 say "Enter Second Number : " get No2
Read
@9,10 say "Enter Third Number : " get No3
Read
if No1>No2 and No1>No3
@11,10 say "The Biggest Number is : " +str(No1)
endif
if No2>No1 and No2>No3
@11,10 say "The Biggest Number is : " +str(No2)
endif
if No3>No1 and No3>No2
@11,10 say "The Biggest Number is : " +str(No3)
endif
Program 11
Write a program to accept a number and check whether it is divisible by 5 or not
Set talk off
clear
No=0
@5,10 say "Enter any Number : " Get No
Read
If No%5 =0
@7,10 say " This number divisible by 5 "
Else
@7,10 say " This number not divisible by 5 "
Endif
Program 12
Write a program to print 100, 95, 90, 85, 80, 75, 70, 65, 60, 55
clear
set talk off
No=100
for ctr=10 to 1 step -1
?No
No=No-5
Endfor

You might also like