Saturday, October 22, 2016

Qbasic Program: Display series



193.   WAP to display all natural numbers from 1 to 100.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 100
PRINT I,
NEXT I
END SUB


194. WAP to display all odd numbers from 1 to 100.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 100 STEP 2
PRINT I,
NEXT I
END SUB

195. WAP to display all even numbers from 2 to 100.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 2 TO 100 STEP 2
PRINT I,
NEXT I
END SUB
196. WAP to find the sum of all natural numbers from 1 to 100.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 100
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END SUB
197. WAP to find the sum of all odd numbers from 1 to 100.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 1 TO 100 STEP 2
S = S + I
NEXT I
PRINT “SUM OF ALL ODD NUMBERS FROM 1 TO 100=”; S
END SUB
198. WAP to find the sum of all even numbers from 2 to 100.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 2 TO 100 STEP 2
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END SUB
199. WAP to display all natural numbers from 1 to 100 in descending order.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 100 TO 1 STEP - 1
PRINT I,
NEXT I
END SUB

200. WAP to display all odd numbers from 1 to 100 in descending order.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 99 TO 1 STEP - 2
PRINT I,
NEXT I
END SUB


201. WAP to display all even numbers from 2 to 100 in descending order.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 100 TO 2 STEP - 1
PRINT I,
NEXT I
END SUB
202. WAP to display all natural numbers from 1 to 100 also display its sum.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END : SUB SERIES
FOR I = 1 TO 100
PRINT I,
S = S + I
NEXT I
PRINT “SUM OF ALL NATURAL NUMBERS FROM 1 TO 100=”; S
END SUB
203. WAP to display all odd numbers from 1 to 100 also display its sum.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 1 TO 100 STEP 2
PRINT I,
S = S + I
NEXT I
PRINT “SUM OF ALL ODD NUMBERS FROM 1 TO 100=”; S
END SUB
204. WAP to display all even numbers from 2 to 100 also display its sum.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 2 TO 100 STEP 2
PRINT I,
S = S + I
NEXT I
PRINT “SUM OF ALL EVEN NUMBERS FROM 1 TO 100=”; S
END SUB
205. WAP to display cube of all numbers from 1 to 50.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 1 TO 50
PRINT I ^ 3,
NEXT I
END SUB

206. WAP to display square of all numbers from 1 to 50.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 1 TO 50
PRINT I ^ 2,
NEXT I
END SUB

207. WAP to print the sum of the numbers between 2 to 50.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 2 TO 50
S = S + I
NEXT I
PRINT “SUM OF NUMBERS BETWEEN 2 TO 50” ; S
END SUB
208. WAP to print the sum of square of odd numbers up to 100.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 100 STEP 2
S = S + I ^ 2
NEXT I
PRINT “SUM OF SQUARE OF ODD NUMBERS UP TO 100” ; S
END SUB


209. WAP to print the sum of the numbers between 3 to 30.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 3 TO 30
S = S + I
NEXT I
PRINT “SUM OF NUMBERS BETWEEN 3 TO 30” ; S
END SUB








210. WAP to print the sum of cube of even numbers between 2 to 50.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 2 TO 50 STEP 2
S = S + I ^ 3
NEXT I
PRINT “SUM OF CUBE OF EVEN NUMBERS BETWEEN 2 TO 50” ; S
END SUB
211. WAP to print the sum of even numbers between 2 to 50.
DECLARE SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
FOR I = 2 TO 50 STEP 2
S = S + I
NEXT I
PRINT “SUM OF EVEN NUMBERS BETWEEN 2 TO 50” ; S
END SUB
212. WAP using to print the sum of first ten positive integers.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
FOR I = 1 TO 10
S = S + I
NEXT I
PRINT “SUM OF FIRST  TEN POSITIVE INTEGERS” ; S
END SUB
213. WAP to print first ten multiples of input number.

CLS
INPUT “ENTER ANY NUMBER”; N
FOR I = 1 TO 10
PRINT N * I,
NEXT I
END

DECLARE SUB SERIES ( N)
CLS
INPUT “ENTER ANY NUMBER”; N
CALL SERIES (N)
END

SUB SERIES (N)
FOR I = 1 TO 10
PRINT N * I,
NEXT I
END SUB

214. WAP using  to display first 13 odd numbers.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
A = 1
FOR I = 1 TO 13
PRINT A,
A = A+ 2
NEXT I
END SUB





215. WAP using to display first 19 even numbers.

DECLARE SUB SERIES ( )
CLS
CALL SERIES
END

SUB SERIES
A = 2
FOR I = 1 TO 19
PRINT A,
A = A+ 2
NEXT I
END SUB

No comments:

Post a Comment