QBASIC programs FOR THE FOLLOWING PROBLEMS:
a.) Write a program that asks marks in any subject and display the message "Result pass" if the input number is greater than 40.CLS
INPUT "Enter Percentage";P
IF P>=40 THEN PRINT "You are pass" ELSE PRINT "You are fail"
END
b.) Write a program to find a greater among two number.
CLS
INPUT "Enter any two number"; a, b
IF a>b then
PRINT " The greater number is";a
ELSE
PRINT " The greater number is";b
END IF
END
c.) Write a program to input a number and check whether it is odd or even.
CLS
INPUT " Enter any number"; N
IF A MOD 2-0 THEN
PRINT "Even number"
ELSE
PRINT "Odd number"
END IF
END
d.) Write a program that asks any 2 no and display the difference between greater and smaller number.
CLS
INPUT " Enter any two number ";a,b
IF a>b THEN
D=a-b
ELSE
D=b-a
END IF
END
e.) Write a program that asks your age and tells whether you are eligible to vote or not.
CLS
INPUT " Enter age";a
IF a>=18 THEN
PRINT "You can vote"
ELSE
PRINT "You cannot vote"
END IF
END
f. ) Write a program to input any 3 no and display the smallest number.
CLS
INPUT " Enter any three number"a,b
IF a <b and b <c then
PRINT " The smallest number is";a
ELSE IF b <a AND b <c THEN
PRINT "The smallest number is";b
ELSE
PRINT " The smallest number is";c
END IF
END
g.) Write a program that asks marks in 3 different subject and display message pass or fail.
CLS
INPUT "Enter marks in 3 subjects";a,b,c
IF a>=40 AND b>=40 AND c>=40
THEN
PRINT "You are pass"
ELSE
PRINT "You are fail"
END IF
END
h. ) Write a program using FOR...NEXT statement to print natural number up to 15.
CLS
FOR I= 1 TO 15
PRINT I
NEXT I
END
I. ) Write a program using FOR..NEXT statement to print even number 2 to 20.
CLS
FOR I = 2 TO 20 STEP 2
PRINT I
NEXT I
END
j.) Write a program using WHILE.WEND statement to print first 10 odd numbers.
CLS
FOR I= 1 TO 10 STEPS 2
PRINT I
NEXT I
END
k. ) Write a program using DO WHILE...... LOOP statement to generate numbers:2,5,8,11........32
CLS
FOR I= 2 TO 32 STEP 3
PRINT I
NEXT I
END
L.) Write a program to print numbers;100,95,90.........5 using anyone of the looping structure.
CLS
FOR I= 100 TO 5 STEP-5
PRINT I
NEXT I
END
m.) Write a program to print summer of first 15 natural number using any one of the looping structure.
CLS
FOR I=1 TO 15
S= S+I
NEXT I
PRINT "SUM";S
END
n.) Write a program to print sum of even numbers from 2 to 10 using any one of the looping structure.
CLS
FOR I = 2 TO 10 STEP 2
S=S+I
NEXT I
PRINT "SUM";S
END
o.) Write a program to print sum of odd number between 2 to 21 using anyone of the looping structure.
CLS
FOR I= 2 TO 21 STEP 2
S= S+I
NEXT I
PRINT "SUM";S
END
p.) Write a program to print even numbers from 20 to 40.
CLS
FOR I= 20 TO 40 STEP 2
PRINT I
NEXT I
END
q.) Write a program to find a product of first ten natural numbers.
CLS
P=1
FOR I= 1 TO 10
P= P*1
NEXT I
PRINT " Product ";P
END
r.) Write a program to generate multiplication table of input numbers.
CLS
INPUT "Enter any number";N
FOR I= 1 TO 10
PRINT n;"x":i:"=";n*1
NEXT I
END
s.) Write a program to print numbers 1,8,27,.......,1000.
CLS
FOR I=1 TO 18
PRINT 1^3
NEXT I
END
No comments:
Post a Comment