0% found this document useful (0 votes)
52 views

Basic Progamming Language

This document contains 10 programming questions and their solutions. It asks the reader to write programs to calculate the area and perimeter of a rectangle, simple interest, addition/subtraction/multiplication/division of two numbers, check if a number is even or odd, calculate student marks, print a number table, calculate factorial of a number, find the largest of input numbers, print number series, and print number patterns. Sample inputs and outputs are provided for each program.

Uploaded by

accord123
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Basic Progamming Language

This document contains 10 programming questions and their solutions. It asks the reader to write programs to calculate the area and perimeter of a rectangle, simple interest, addition/subtraction/multiplication/division of two numbers, check if a number is even or odd, calculate student marks, print a number table, calculate factorial of a number, find the largest of input numbers, print number series, and print number patterns. Sample inputs and outputs are provided for each program.

Uploaded by

accord123
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Q1: Write a program to get area and perimeter of a rectangle?

10 INPUT LENGTH, L 20 INPUT WIDTH, B 30 A = L* B 40 P = 2* (L+B) 50 PRINT AREA, A 60 PRINT PERIMETER, P 70 END

OUTPUT
LENGTH = 100 BREATH = 20 AREA = 2000 PERIMETERN = 240

Q2: Write a program to print simple interest.


10 INPUT PRINCIPAL, P 20 INPUT RATE, R 30 INPUT TIME, T 40 SI (P*R*T) /100 50 PRINT SIMPLE INTREST; SI 60 END

OUTPUT
PRINCIPAL = 200 RATE = 100 TIME =3 SI = 600

Q3: Write a program to print addition, subtraction, division and multiplication of two numbers?
10 X = 2 20 Y = 20 30 A =X+Y 40 B =X- Y 50 C =X*Y 60 D =X \ Y 70 PRINT A, B, C, D 80 END

OUTPUT
SUM =22 SUB = 18 PRODUCT= 40 DIVISION = .1

Q4: Write a program to check whether the number input is even or odd?
10 INPUT ANY NUMBERS, A 20 IF A MOD 2=0 THEN PRINTODDELSE PRINT EVEN 30 END

OUTPUT
ENTER ANY NO= 55 ODD OUTPUT ENTER ANY NO= 50 EVEN

Q5: Write a program to get roll number, name and marks in three different subjects and point total marks obtained percentage and grade obtained by the students?
10 INPUT ROLL; R 20 INPUT NAME=,N$ 30 INPUT MARKS IN ENGLISH=, E 40 INPUT MARKS IN MATHS=, M 50 INPUT MARKS IN COMPUTER=, C 60 T = E+M+C 70 P = T/3 80 IF P > 60, THEN D$ = 1 GO TO 120 90 IF P > 45, THEN D$ = 2 GO TO 120 100 IF P > = 33, THEN D$ = 3 GO TO 120 110 D $ = FAIL 120 PRINT ROLL; R 130 PRINT NAME; N$ 140 PRINT MARKS IN 3 SUBJECTS=; E, M, C 150 PRINT TOTAL=; T 160 PRINT PERCENTAGE=; P 170 PRINT DIVISION=; D$ 180 END

OUTPUT
ROLL=75 NAME=PRERNA MARKS IN ENGLISH=78 MARKS IN MATH=79

MARKS IN COMPUTER=56 MARKS IN 3 SUBJECTS= 78 TOTAL=213 PERCENTAGE= 71 DIVISION=1

79

56

Q6: Write a program get table of a number?


10 INPUT GIVE A NUMBER, N 20 FOR 1 = 1 TO 10 30 P = N*1 40 PRINT N; *; 1; =; P 50 NEXT 60 END

OUTPUT
ANY NO=5 5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45 5*10=50

Q7; Write a program to print factorial of a number?

10 REM TO FIND FACTORIAL 20 INPUT ANY NUMBER, N 30 F =1, 40 FOR C = N TO 1 STEP-1 50 F = F*C 60 NEXT 70 PRINT FACTORIAL, F 80 END

OUTPUT
GIVE ANY NO =8 FACTORIAL = 40320

Q8: Write a program to print smallest of n input number?

10 REM TO FIND LARGEST OF N NO 20 INPUT HOW MANY NUMBER, NUMBER, N 30 MAX = 0 40 FOR C = 1TO N 50 INPUT NUMBER, NO M 60 IF NUM > MAX THEN = NUM 70 NEXT 80 PRINT MAXIMUM, =MAX 90 END

OUTPUT
HOW MANY NO=5 ? 45 ? 69 ? 40 ? 13 ? 100 MAXIMUM =100

Q9: Write a Program to print some of the series. (a)- 1+3+5+7+ N terms
10 INPUT HOW MANY NO N 20 FOR I = 1 TO N STEP 2 30 S= S+I 40 NEXT 50 PRINT SUM OF SERIES; S 60 NEXT 70 PRINT 80 NEXT 90 END

OUTPUT
ANY NO= 11 2+ 4+ 6+ 8+ 10+

(b)- 22 + 42 + 62 + 8 2 + . N terms.
10 INPUT HOW MANY NO N 20 FOR I = 2 TO N STEP 2 30 S = S+ I*I 40 NEXT 50 PRINT SUM OF SERIES; N 60 NEXT 70 PRINT 80 NEXT 90 END

OUTPUT
ANY NO= 11 4, 16, 36, 64, 100,

Q10: Write A Program to Print The Following Pattern:(a) 1 12 123


10 20 30 40 50 60 70 FOR I= 1 TO 3 FOR J = 1 TO I PRINT J; ;; NEXT PRINT NEXT END

OUTPUT
1 12 123

(b)

1 22 333
10 FOR I= 1 TO 3 20 FOR J = 1 TO I 30 PRINT I; ; 40 NEXT 50 PRINT 60 NEXT 70 END

OUTPUT
1 22 333

You might also like