Qbasic programming
1. Write a program to input any number and check wheather the given number is divisible by 3 and 7 or not.
ClSINPUT “enter any number”;n
If n MOD 3=0 and n MOD 7=0 THEN
PRINT”The given number is divisible by 3 and 7”
ELSE
PRINT”The given number is not divisible by 3 and 7”
END IF
END
2. WAP to input any number and check wheather the given number is positive or negative.
CLSINPUT”Enter any number”;n
IF n>0 THEN
PRINT “The given number is positive”
ELSEIF n<0 THEN
PRINT”The given number is negative “
END IF
END
3. WAP to input any number and display wheather it is odd or even.
ClSINPUT “ENTER any number”;n
IF n MOD 2=0 THEN
PRINT “The given number is even”
ELSE
PRINT “The given number is odd”
END IF
END
4. WAP to enter any two number and display the smaller one.
CLSINPUT “Enter any two number “;A,B
IF A<B THEN
PRINT “The smaller number is “;A
ELSE
PRINT “The smaller number is”;B
END IF
END
5. WAP to enter 3 numbers and display the middle number.
CLSINPUT “Enter 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. WAP to check wheather the input number is divisible by 13 or not.
ClSINPUT”Enter any number “;N
IF N MOD 13=0 THEN
PRINT”Number is divisible by 13”
ELSE
PRINT “Number is not divisible by 13”
END IF
END
7. WAP to check wheather the input number is positive,negative or zero.
CLSINPUT “Enter any number “;N
IF N>0 THEN
PRINT “Number is positive “
ELSEIF N<0 THEN
PRINT “Number is negative “
ELSE
PRINT “Number is zero”
END IF
END
8. WAP to input a year and display wheather that year is a leap year or not.[divisible by 4 but not 100.]
CLSINPUT “Enter year”;Y
IF Y MOD 4=0 AND 100<=0 OR Y MOD 400=0
THEN
PRINT “The given year is leap year”
ELSE
PRINT “The given year is not leap year”
END IF
END
9. WAP to input age of a person and find out wheather the person is eligible to drive or not.[age>16]
CLSINPUT “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. WAP to enter three numbers & display the greatest one.
CLSINPUT “Enter 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
Comments
Post a Comment