PRINT Statement: Display information on screen.
Syntax:
PRINT “Sample text”
OR
age = 13
PRINT age
PRINT “Age is =”;age
INPUT Statement: It helps to take input from the user.
Syntax:
INPUT variable_name
INPUT “Any text”;VN
Q1) Write a program to calculate area of rectangle. [A=l*b]
CLS
INPUT “Enter length”;l
INPUT “Enter Breadth”;b
A=l*b
PRINT “Area is: ”;A
ENDQ2) WAP to calculate simple interest [i=(p*t*r)/100]
CLS
INPUT “Enter principal”;p
INPUT “Enter time”;t
INPUT “Enter rate”;r
i=(p*t*r)/100
PRINT “Simple interest is: ”;i
ENDQ3) WAP to calculate volume of cylinder. [v=pr2h]
CLS
pi = (22/7)
INPUT “Enter radius”;r
INPUT “Enter height”;h
v = pi*r^2*h
PRINT “Volume is”;v
ENDQ4) WAP to calculate average of three number. [Av=(a+b+c)/3]
CLS
INPUT “Enter first number”;a
INPUT “Enter second number”;b
INPUT “Enter third number”;c
av=(a+b+c)/3
PRINT “Average is: ”;av
ENDQ5) WAP to convert Nepali rupee into American dollar. [1$ = 118Rs]
CLS
INPUT “Enter Nepali rupee”; N
A = N/118
PRINT “America dollar”; A
ENDQ6) WAP to convert Celsius temperature into Fahrenheit. c − 0 100 = f − 32 180 𝑐-0100=𝑓-32180
18*c = 10*f-320
18*c+320 = 10*f
f = (18*c+320)/10
C = (10*f-320)/18
CLS
INPUT “Enter Celsius”; c
f = (18*c+320)/10
PRINT “Fahrenheit temperature”; f
ENDIF Statement:
- IF statement
- IF ELSE statement
- ELSEIF statement
1) IF statement
Syntax:
IF (condition) THEN
Block of statements//
END IF
Program example:
CLS
INPUT “Enter your age”; a
IF a>18 THEN
PRINT “You are eligible to vote”
END IF
ENDCLS
INPUT “Enter your percentage”; p
IF p>=40 THEN
PRINT “You are pass”
END IF
END2) IF ELSE statement
Syntax:
IF (condition) THEN
Block of statements no.1//
ELSE
Block of statements no.2//
END IF
Program example:
CLS
INPUT “Enter your age”; a
IF a>18 THEN
PRINT “You are eligible to vote”
ELSE
PRINT “You are not eligible to vote”
END IF
ENDCLS
INPUT “Enter your percentage”; p
IF p>=40 THEN
PRINT “You are pass”
ELSE
PRINT “You are fail”
END IF
ENDQ1) Write a program to input 2 different numbers and find the greatest number.
CLS
INPUT “Enter two number”; a,b
IF a>b THEN
PRINT a; “is greatest”
ELSE
PRINT b; “is greatest”
END IF
ENDQ2) Write a program to check whether the given number is odd or even.
CLS
INPUT “Enter a number” ; n
a = n MOD 2
IF a=0 THEN
PRINT n; ”is Even”
ELSE
PRINT n; ”is Odd”
END IF
ENDQ3) Write to check whether the given number is exactly divisible by 5 and 7.
CLS
INPUT “Enter a number” ; n
a = n MOD 5
b = n MOD 7
IF a=0 AND b=0 THEN
PRINT n;” is divisible by both 5 and 7”
ELSE
PRINT n;”is not divisible by both 5 and 7”
END IF
END
Leave a comment
Your email address will not be published. Required fields are marked *