Friday, June 22, 2018

Q-Basic Programs





1.  Write a program to input any number and check whether the given number is divisible by 3 and 7 or not.

CLS
INPUT "Enter any number"; N
IF N MOD 3=0 AND N MOD 7=0 THEN
PRINT "The number is divisible by 3 and 7"
ELSE
PRINT "The number is not divisible by 3 and 7"
END IF
END

2. Write a program to input any number and check whether the give number is positive or negative.

CLS
INPUT "Enter any number"; N
IF N > 0 THEN
PRINT "Positive number"
ELSEIF  N < 0  THEN
PRINT  " Negative number"
END IF
END

3.Write a program to input any number and display whether it is odd or even.

CLS
INPUT "Enter any number"; N
IF N MOD 2=0 THEN
PRINT "Even number"
ELSE
PRINT "Odd number"
END IF
END

4. Write a program to enter any two numbers and display the smaller one.

CLS
INPUT "Enter any two numbers"; a, b
IF a<b THEN
PRINT "The smallest number is"; a
ELSE
PRINT "The smallest number is"; b
END IF
END

5.Write a program to enter any three numbers and display the middle number.

CLS
INPUT "Enter any three numbers"; a, b, c
IF a>b AND a<c  OR  a<b AND a>c  THEN
PRINT "The middle number is";a
ELSEIF b>a AND b<c OR b<a AND b>c THEN
PRINT "The middle number is";b
ELSE 
PRINT "The middle number is";c
     END IF
END

6.Write a program to test whether a user input number is completely divisible by 13 or not.

CLS
INPUT "Enter any number"; N
IF N MOD 13=0 THEN
PRINT "The number is completely divisible by 13"
ELSE
PRINT "The number is not completely divisible by 13"
END IF 
END

7.Write a program to check whether a input number is positive, negative or zero.

CLS
INPUT "Enter any number"; N
IF N>0 THEN 
PRINT "Positive number"
ELSEIF N<0 THEN 
PRINT "Negative number"
ELSE
PRINT "The number is zero"
END IF
END

8. Write a program to input a year and display whether that year is a leap year or not.


CLS

INPUT  "Enter year"; Y
IF Y MOD 4=0 AND Y MOD 100 <> 0 OR Y MOD 400=0 THEN
PRINT "The year is leap year"
ELSE
PRINT "The year is not leap year"
END IF 
END

9. Input the age of a person and find out whether the person is eligible to drive or not.

CLS
INPUT "Enter your age"; A
IF A>= 16 THEN
PRINT "You are eligible to drive"
ELSE
PRINT "You are not eligible to drive"
END IF 
END

10.Write a program to enter any three numbers and display the greatest one.

CLS
INPUT "Enter any three numbers"; a, b, c
IF a>b AND a>c THEN
PRINT "The greatest number is"; a
ELSEIF b>a AND b>c THEN 
PRINT "The greatest number is";b
ELSE
PRINT "The greatest number is";c
END IF 
END

No comments:

Post a Comment

Experience of COVID-19 and the cancellation of SEE.

As we know, that this pandemic disease has started from the Wuhan district of China. This viruswvirus discovered out on 31st December 2019 ...