Computer Science, asked by bhowmicksatyam32, 7 months ago

1. Write a program in QBASIC to print the given pattern, the number
of rows should be taken as input. (In the pattern given below the
number of rows entered is: 5]
1
101
10101
1010101
101010101
2. Write a program in QBASIC to print the given series up to N terms,
the value of N is to be taken as input.
1-3+5-7+9 ....... N terms

Do In Q- Basic.​

Answers

Answered by RuwaisnZaid
8

Explanation:

1.for I in range(5):

for j in range(0,I+1):

if j%2==0:

print("1",end=" ")

else:

print("0",end=" ")

print()

for i in range(1,n,2):

u = i

if i%2==0:

print(u,"-",i,end=" ")

Answered by anindyaadhikari13
8

Question 1:-

Write a program in QBASIC to print the following pattern. The number of rows should be taken as input.

1

101

10101

1010101

101010101

Program:-

CLS

INPUT "ENTER THE NUMBER OF ROWS: ";N

FOR I = 1 TO N STEP 1

FOR J=1 TO 2*I-1 STEP 2

PRINT J MOD 2 +" "

NEXT J

PRINT

NEXT I

Question 2:-

Write a QBASIC program to print the series upto N terms.

1 -3 5 -7 9 -11....

Program:-

CLS

INPUT "ENTER THE NUMBER OF TERMS FOR THE SERIES: ";N

A=1

FOR I = 1 TO N STEP 1

IF I MOD 2=1 THEN

PRINT A+" "

ELSE

PRINT (A*-1) +" "

END IF

A=A+2

NEXT I

END

Similar questions