Computer Science, asked by drawwithadarsh, 6 months ago

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

Answers

Answered by anindyaadhikari13
4

Question:-

Write a qbasic program to print the series upto n terms.

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

Program:-

CLS

INPUT "ENTER N: ";N

A=1

FOR I=1 TO N STEP 1

IF I MOD 2=1

IF I=1 THEN

PRINT A

ELSE

PRINT "+"+A

END IF

ELSE

PRINT -1*A

END IF

A=A+2

NEXT I

END

Answered by BrainlyProgrammer
3

Answer:

CLS

INPUT N

d=1

FOR I=1 TO N

IF I MOD 2=1

THEN

IF I =1

THEN PRINT d

ELSE

PRINT "+"+d

ENDIF

ELSE

PRINT (-1*d)

ENDIF

d=d+2

NEXT I

END

Output:

+1-3+5-7+9...Nth term

Similar questions