Saturday, August 26, 2017

QBASIC Programs



1. 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 IF 
END

2. Write  a program that asks any two  numbers  and  display  the  greater  one .


CLS

INPUT "Enter  any  two  numbers " ; a , b
IF a > b THEN 
PRINT " the greater  number is " ; a
ELSE 
PRINT " the  greater  number is " ; b
END IF 
END 

3. Write  a  program  that  checks  whether  the  supplied  number  is  even  or  odd .


CLS

INPUT " Enter  a number  " ; n
IF  n  MOD  2 = 0  THEN 
PRINT  "  even  number "
ELSE 
PRINT " odd  number "
END IF 
END 

4. Write a program  that  asks  your  age  and  check  whether  you  can  vote or not . 


CLS 

INPUT " Enter  a age " ; a
IF a > = 18  THEN 
PRINT " you  can vote " ; 
ELSE 
PRINT " You cannot vote " ;
END IF 
END 

5 .Write a program  to  input  any  three  numbers  and  display  the  smallest  numbers .


CLS 
INPUT " Enter any three  number is " ,  a ,  b , c 
IF a <  b  AND  a <  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 

6 . Write  a program  that  asks  marks  of  three  different  subject  and  display  message  pass  or         fail .


CLS 

INPUT " Enter  marks  in  three 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 

7. Write  a program  that  asks  any  two  numbers  and  display  the  differences  between  greater       and  smaller   number  . 


CLS 

INPUT "  enter  any  two   numbers " ;  a , b 
IF  a < b THEN 
d =  a - b 
ELSE 
d = b - a
END IF 
PRINT  "  the difference  is  " ; d
END

8 . Write  a  program  using  FOR.........NEXT  statement to print natural numbers  up to  15 .

  
CLS 
FOR  i  = 1 to 15 
PRINT  i 
NEXT i 
END 

9 . Write  a  program  using  FOR.........NEXT  statement to print even  numbers from 2 to 20 .


CLS 

FOR  i = 2 TO 20 STEP 2 
PRINT i 
NEXT i 
END

10 .Write  a  program  using  FOR.........NEXT  statement to  print  first  10  odd  numbers . 


CLS  

FOR  i =  1  TO 20  STEP 2 
PRINT i 
NEXT i 
END

11. Write  a  program  using  FOR.........NEXT  statement to generate  numbers .2 , 8 , 11 , ....... 32 .


CLS  

FOR  i =  2  TO  32  STEP  3 
PRINT i 
NEXT i 
END

12. Write a program  to  print  numbers  ,  100 , 95 , 90 .........5  using  any  one  of  the  looping             structures .


CLS 

FOR  i =  100 TO 5  STEP  5
PRINT i 
NEXT i 
END 

13 .Write a program  to  print  sum  of  first  15  natural  numbers .


 CLS 

FOR  i =  1 TO 15 
S = S + i 
NEXT i 
PRINT  " sun =" ; s
END 

14 .Write a program  to  print  sum  of  odd  number  from  2 to 10.


CLS 

FOR  i =  2  TO  10  STEP  2 
S = S + i 
NEXT i 
PRINT  " sun =" ; s
END 

15 .Write a program  to  print  sum  of  odd  number  from 1 to 21 .

CLS 
FOR  i = 1 TO 21  STEP  2 
S = S + i 
NEXT i 
PRINT  " sun =" ; s
END 

16.Write a program  to  print even number  from 20  to 40 .


CLS 

FOR  i = 20 TO 40  STEP  2
PRINT i  
NEXT i 
END 

17. Write  a  program  to  find  product  of  first  ten  natural  numbers . 


CLS 

P = 1 
FOR i = 1 TO 10 
P = P * i 
NEXT i 
PRINT " product ="; P 
END

18. Write a program  to  generate  multiplication  table  of  input  number .


CLS 

INPUT " enter  any  number  "; n
FOR  i =  1 TO 10
PRINT  n ; "x" ; i ; "=" n * i 
NEXT i 
END 

19 . Write a program to print  numbers  1 , 8 , 27 ,........... 1000.


CLS 

FOR i  = 1 TO  10 
PRINT  i ^ 3
NEXT i 
END 

No comments:

Post a Comment