Showing posts with label Q-basic. Show all posts
Showing posts with label Q-basic. Show all posts

Friday, November 5, 2021

Q-BASIC Program (WAP to find a factor, reverse order, series, palindrome, Armstrong, prime, and composite)

Q-BASIC Program (WAP to find a factor, reverse order, series, palindrome, Armstrong, prime, and composite)

Write a program to display the following series:

1.   3  9  27  81............. up to 10th terms

CLS

FOR X=1 TO 10

N=3^X

PRINT N;

NEXT X

END

2. 100  97.5  95  92.51....up to 10th terms

CLS

N=100

FOR I = 1 TO 10

PRINT N;

N = N-2.5

NEXT I

END

3.  7    77    777     7777    77777

CLS

A=7

FOR I=1 TO 5

PRINT A;

A-A*10+7

NEXT I

END


4.   2   1   3    4    7   -------------- UP TO 10TH TERMS. (FIBONACCI SERIES)

CLS

A=2

B=1

PRINT A; B;

FOR 1=1 TO 8

C=A+B

PRINT C;

A=B

B=C

NEXT 1

END


Or

CLS

A=2

B=1

FOR 1-1 TO 5

PRINT A; B;

A=A+B

B=A+B

NEXT I

END


5.    55555    5555   555   55    5

CLS

P=55555

X=1

WHILE X<=5

PRINT P;

P=P\10

X=X+1

WEND

END


6. Write a program to display the factorial of a given number.

CLS

INPUT "Enter a number"; N

P=1

FOR I=1 TO N

P=P*I

NEXT I

PRINT "Factorial is;" ;P

END


7. Write a program to input any input number and print it in reverse order.

CLS

INPUT "Enter any number"; N

WHILE N<>0

R=N MOD 10

S= (S*10)+R

N=N\10

WEND

PRINT "Reverse of the given number is"; S

END


8. Write a program to input any number and display the sum of individual digits of the given number.

CLS

INPUT "Enter any number"; N

WHILE N<> 0

R=N MOD 10

S=S+R

N=N\10

WEND

PRINT "The sum of individual digits is"; S

END


9. Write a program to display the factors of the given number.

CLS

INPUT "Enter a number"; NUM

FOR I= 1 TO NUM

IF NUM MOD I=0 THEN

PRINT I;

END IF

NEXT I

END


10. Write a program to enter a number and check whether the number is palindrome or not.

CLS

INPUT "Enter a number"; N

P=N

DO WHILE N<>0

 R=N MOD 10

S=S*10+R

N=N\10

LOOP

IF P=S THEN 

PRINT "The number is a palindrome"

ELSE

PRINT "The number is not a palindrome"

END IF

END


11. Write a program to input a number and check whether the number is Armstrong or not. The number is called Armstrong if the sum of the cubes of each individual digit is equal to the given number]

CLS

INPUT "Enter a number"; N

P=N

WHILE NO

R=N MOD 10

A=A+R^3

N= N \ 10

WEND

IF A =P THEN

PRINT "The number is Armstrong"

ELSE

PRINT "The number is not Armstrong"

ENDIF 

END


12. Write a program to input any number from the user and then display whether it is prime or composite.

CLS 

INPUT "ENTER ANY NUMBER"; N

FOR I=1 TO N

R=N MOD I

IF R=0 THEN

C=C+1 

ENDIF

NEXT I

IF C=2 THEN

PRINT "THE GIVEN NUMBER IS PRIME"

ELSE

PRINT "THE GIVEN NUMBER IS COMPOSITE"

ENDIF 

END


13. Write a program to display all the prime numbers from 2 to 100.

CLS 

FOR I = 2 TO 100

C=0

FOR J = 1 TO I

R = I MOD J

IF R = 0 THEN

C=C+1

ENDIF

NEXT J

IF C=2 THEN 

PRINT I;

ENDIF

NEXT I 

END


Wednesday, November 3, 2021

Q-basic programs (To Find name, odd, even, series, multiplication table, divisible, a sum of even or odd numbers)

Q-basic programs (To Find name, odd, even, series, multiplication table, divisible, a sum of even or odd numbers)

1. How do you write a flowchart and QBasic code to generate series 5, 10, 15, 20, up to 10 terms?

CLS
A=5
FOR I = 1 TO 10
PRINT A;
A=A+5 
NEXT I 
END

2. How do you write a program in QBasic to write a table of 1 to 10 number
CLS
FOR I = 1 TO 10
FOR J = 1 TO 10
PRINT J ;"*"; I ;"="; (J*I)
NEXT J
NEXT I
END

3. How do I write a QBASIC program for multiples of 9?
CLS
A =9
FOR I = 1 TO 10 
PRINT A; "*";I; "="; ( A*I)
NEXT I 
END

4. WAP To print my school name 100 times?

CLS
A$ = "ENTER YOUR SCHOOL NAME"
FOR I =1 TO 100
PRINT A$ 
NEXT I 
END

5. WAP To print my name 20 times?

CLS
A$ = "ENTER YOUR NAME"
FOR I =1 TO 100
PRINT A$ 
NEXT I 
END

6. How do you write a QBasic program to check whether a number is exactly divisible by 3 or 7?

CLS 
INPUT ''ENTER A NUMBER"; N
IF N MOD 3 = 0 AND N MOD 7 = 0 THEN
PRINT "THE NUMBER IS DIVISIBLE BY 3 OR 7"
ELSE 
PRINT ''THE NUMBER IS NOT DIVISIBLE BY 3 OR 7"
ENDIF

END


Saturday, October 30, 2021

Q-basic Problem (WAP-to-find-even-odd-eligible-for-vote-or-not-divisible-greater-isoceles)

Q-basic Problem (WAP-to-find-even-odd-eligible-for-vote-or-not-divisible-greater-isoceles)

1. Write a program to input the age of the person and check whether the person is eligible to vote.

CLS

INPUT "Enter your age"; A

IF A >= 18 THEN

PRINT "You are eligible to vote"

END IF

END

2. Write a program to input any number and check whether the number is even or odd.

CLS

INPUT "Enter any number"; NUM

IF NUM MOD 2= 0 THEN

PRINT "The given number is even"

ELSE

PRINT "The given number is odd"

END IF

END


3. Write a program to input the age of a person and check whether the person is eligible to vote or not.

CLS

INPUT "Enter age of person"; A

IF A >=18 THEN

PRINT "Person is eligible to vote"

ELSE

PRINT "Person is not eligible to vote"

END IF

END

4. Write a program to display whether the given number is exactly divisible or not.

CLS

INPUT "Enter any number"; N

IFN MOD 7= 0 THEN

PRINT "The given number is exactly divisible by 7"

ELSE

PRINT "The given number is not exactly divisible by 7"

END IF

END

5. Write a program to display the greatest number among any three different numbers.

CLS

INPUT "Enter the first number"; N1

INPUT "Enter the second number"; N2

INPUT "Enter the third number"; N3

IF N1>N2 AND N1>N3 THEN

PRINT "The greatest number is"; N1 ELSEIF N2>N1 AND N2>N3 THEN

PRINT "The greatest number is"; N2

ELSE

PRINT "The greatest number is"; N3

END IF

END

6. Write a program to input three sides of a triangle and display whether the triangle is equilateral, isosceles, or scalene.

CLS

INPUT "Enter the first side"; A

INPUT "Enter the second side"; B

INPUT "Enter the third side";C

IF A=B AND B=C AND C=A THEN

PRINT "The triangle is equilateral"

ELSEIF A<>B AND B<>CAND C<>A THEN

PRINT "The triangle is scalene"

ELSE

PRINT "The triangle is isosceles"

END IF

END



Friday, September 24, 2021

QBASIC problem, class7,8,9,10.(to find string, factorial, prime, odd, even, palindrome, armstrong, si, area, patterns)


 

QBASIC problem, class7,8,9,10.(to find the string, factorial, prime, odd, even, palindrome, Armstrong, si,  area, patterns)

1. WAP to print character in even position in a string,

CLS
INPUT"ENTER A STRING"; A$
FOR I = 1 TO LEN$ (A$)
IF I MOD 2 =0 THEN S$=S$+MID$ (A$,I,1)
NEXT I
PRINT "THE LETTER IN POSITION IS"; S$ 
ENDIF 
END

2. WAP to find factorial of a given number.

CLS 
F=1
INPUT "ENTER A NUMBER"; A 
FOR I = A  TO 1      STEP -1
F= F*I
NEXT I 
PRINT " THE FACTORIAL IS''; F
END


3. WAP is a program to check given number is prime or not.

CLS 
 INPUT '' ENTER A NUMBER'';A 
FOR I =1 TO A      STEP 1
IF A MOD I= 0  THEN C=C+1
NEXT I 
IF C=2 THEN
PRINT ''PRIME"
ELSE
 PRINT"NOT PRIME"
ENDIF 
END

4. WAP is a program to display all odd numbers between 100 to 200.

FOR I= 100 TO 200

IF I MOD 2= 1 THEN PRINT I

NEXT I 
PRINT I
END

5. WAP  to display multiplication table of 2.

CLS
FOR I= 1 TO 10
PRINT "2"; "*" ; I; "=" ; (2*I)
NEXT I
END

6. WAP to display a multiplication table of 1 to 10.

 CLS
FOR I= 1 TO 10
FOR J= 1 TO 10 
PRINT J; "*'' ;I; "=''; (J*I)
NEXT J 
NEXT I
END

7. WAP is a program to find if an entered number is even or odd.

CLS 
INPUT "ENTER A NUMBER"; A
IF A MOD 2=0   THEN
PRINT ''EVEN"
ELSE
PRINT"ODD"
ENDIF
END

8. WAP is a program to print the sum of even numbers from 2 to 10 using FOR-NEXT          LOOP.

CLS 
FOR I = 2 TO 10  STEP 2
S= S+ I
NEXT I 
PRINT S 
END

9. WAP to print an average of the square of odd numbers from 1 to 9 using WHILE-               WEND Loop.

CLS 
A=1
S=0
C=0
WHILE A<= 9
S=S+A^2
C=C+1
A=A+2
WEND
AVG=S/C
PRINT "AVERAGE IS''; AVG 
END

10. WAP to check if an entered number is palindrome or not.

CLS  
INPUT "ENTER A NUMBER";A 
B=A 
 WHILE A<>0
R=A MOD 10
 C=C*10 +R
A=A/10
IF B=C THEN 
PRINT "PALINDROME"
ELSE 
PRINT"NOT PALINDROME"
ENDIF 
END

11. WAP to find simple interest.

CLS
INPUT "ENTER A NUMBER "; P, T,R
SI= P*T*R/100
PRINT"SIMPLE INTEREST IS"; SI
END

12. WAP to print area of a rectangle.

CLS

INPUT ''ENTER A NUMBER";L,B

A=L*B

PRINT "AREA IS "'A 

END


13. WAP find print the series1,3,5,7,9.........up to 8th term USING FOR-NEXT.

CLS 
FOR I =1 TO 8   STEP2
PRINT I
NEXT I 
END

14. WAP a to print the following pattern:

P R O G R A M
P R O G R A
P R O G R
P R O G 
P R O 
P R 
P
CLS 
A$="PROGRAM"
FOR I = LEN (A$) TO 1   STEP -1
PRINT LEFT$ (A$, I)
NEXT I
END

15. WAP to input an entered number is less than 200 or not.

CLS 
INPUT "ENTER A NUMBER "; A 
IF A<=200 THEN
PRINT '' NUMBER IS LESS THAN 100''
ELSE 
PRINT '' NUMBER IS NOT LESS THAN 200"
ENDIF
END

16. WAP to find the greater number between any two numbers.

CLS
INPUT "ENTER ANY TWO NUMBER "; A, B
IF A<B THEN
PRINT "B IS GREATER"
ELSE
PRINT "A IS GREATER O"
ENDIF
END

17. WAP to find whether a year is a leap year or not.

CLS
INPUT "ENTER A DAYS"; A
IF A=366   THEN
PRINT "A YEAR IS LEAP YEAR"
ELSE
PRINT "A YEAR IS NOT LEAP YEAR"
ENDIF
END

18. WAP to check if an entered number is Armstrong or not.

CLS 
INPUT "ENTER A NUMBER"; N
A=N
WHILE (N<>0)
R=N MOD 10
S=S+R^3
N=N/10
WEND
IF S=A THEN
PRINT "ARMSTRONG"
ELSE
PRINT "NOT ARMSTRONG"
ENDIF 
END

19. WAP a to print the following pattern:

1 2 3 4 5
1 2 3 4 
1 2 3
1 2
1

CLS
A=12345
FOR I = 1 TO 5
PRINT A
A=A/10
NEXT I
END

20. WAP a to print the following pattern:

5 5 5 5 5 
5 5 5 5 
5 5 5
5 5
5
CLS 
A=55555
FOR I =1 TO 5
PRINT A 
A= A/10
NEXT I 
END

  






Wednesday, September 22, 2021

What is Qbasic programming language? Features of Qbasic

What is Qbasic programming language? Features of Qbasic.

QBASIC PROGRAMMING

INTRODUTION TO QBASIC

Q-BASIC stands for Quick Basic All-purpose Symbolic Instruction Code. It is the upgraded version of Basic programming. It is one of the high-level programming languages. It is easy for beginner programmers or students to understand the concept of the language. It uses the interpreter as a translator or language processor. Basic programming was developed by John George Kemeny and Thomas Eugene Kurtz in Dartmouth College, USA in 1964 AD. Qbasic is a high-level programming language. It consists of basic elements from which other elements are formed. The basic elements are character set, variables, constants, operators, expressions, etc.

FEATURES OF THE QBASIC

The features of the Qbasic are as follows:

  • Easy to understand the language and to write the language
  • It is easy to debug the program
  • It is a portable program.
  • It completes the set of file sizes if very small
  • Meaningful words are used in programming syntax 
  • There is a help menu available for the programmer
  • There are two windows or modes: programming mode or indirect mode and other is the direct mode or immediate window

How to download Qbasic and start the Qbasic? (In points)

The ways to download Qbasic and start the Qbasic are given below in the points:
  1. Qbasic 4.5 is available in the market or you can download it from the net as well.
  2. Then after downloading run the qb.exe file.
  3. It opens a text editor programming window.
  4. In the new beginning system, it may be required to install DOSBox 0.74 to start the QBASIC program.
  5. There is a programming mode window in the upper part and immediate mode, a small window in the lower section.
  6. Statements with correct syntax can be used to write a program in the main window.
  7.  Then, there is a menu system and help feature to support the programmer.

What is the Reserved Word in Qbasic?

Reserved Word

The standard words that are well defined in the Qbasic program are called Reserved Word. The reserved words of QBasic are statements, commands, and functions. They are not used to define the variable name, constant name, subroutine name, an array name. The meanings of these words are well defined. Some keywords are PRINT, INPUT, FOR, UNTIL, DO, WHILE, CASE, IF, ELSE, etc.

WHAT IS VARIABLE IN QBASIC?

VARIABLE
Variables are names that are used to store data in a programming language. Its value can be changed during the execution of a program. Variables are needed to allocate the memory of the computer. There are two types of variables. They are:
  1. Numeric variable 
  2. String variable

what are constant in QBASIC?

Constant 
Constant are the names in which it stores fixed value. Constant value doesn't change the execution of the program. It is a predefined value in a program. The rule to define constant is given below:
      Let constantname= value
      Eg: name$= "school"
      X%=5
      Y#=1524

Types of constant

  1. Numeric constant 
  • Integer constant
  • Single precision constant
  • Long integer 
  • Double  precision         
     2. String constant

What are operators?

An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations. Operators are mainly used to manipulate data and variables. They mainly form a part of a mathematical of logical expressions. They can use for both numeric as well as a string values. For examples: +,-.*,<,> etc.

Types of operators

  • Arithmetic operators 
  • Relational operators 
  • Logical operators
  • String operators 
  • Assignment operators
Click here for more...

Sharkey

Simple way to make website using HTML only.

 A simple way to make a website using HTML only. <!DOCTYPE html> <head>         <title>Document</title> </head...