Write output
1. Write
the output of the following program
|
CLS
N=115
P=0
WHILE
N<>0
R=N MOD
2
S=S+R*10^P
P=P+1
N=N\2
WEND
PRINT S
END
|
a.
|
CLS
N=123
P=0
WHILE
N<>0
R=N MOD
8
S=S+R*10^P
P=P+1
N=N\8
WEND
PRINT S
END
|
b.
|
CLS
X=7
FOR C=1 TO 10
PRINT
X;
IF X
MOD 2=0 THEN
X=X/2
ELSE
X=3*X+1
END IF
NEXT C
END
|
|
|
c.
|
|
d.
|
|
|
CLS
N=115
P=0
DO
WHILE N<>0
R=N MOD
2
S=S+R*10^P
P=P+1
N=N\2
LOOP
PRINT S
END
|
e.
|
CLS
N=115
P=0
DO UNTIL
N=0
R=N MOD
8
S=S+R*10^P
P=P+1
N=N\8
LOOP
PRINT S
END
|
f.
|
|
|
|||||
|
2. Read the following program and answer
the questions:
a. CLS
N=115
WHILE N<>0
R=N MOD 8
S=S+R*10^P
P=P+1
N=N/8
WEND
PRINT S
END
i)
What
is the output of the above program?
ii)
What
will be the output of the above program if the statements R= N MOD 8 and N=N\8
will be replaced by statements R= N MOD 2 and N=N\2 respectively.
iii)
What
are the variables used in this program?
iv)
How
many times the statements within WHILE ….WEND loop is executed?
v)
What
will be the output of the above program if the initial value of N is 1024?
vi)
What
will be the output of the given program if the S=S+R*10^P will be replaced by
S=R*10^P
Comments
CLS
C=1:b=2
FOR P=1 TO 10
PRINT C;
SWAP B,C
NEXT P
END
11 PRINT “ENTER THE NUMBER”
12 INPUT a
13 LET SQUARE = N^2
14 PRINT “THE AREA OF SQUARE”; SQUARE
15 END
pls help me with this output
pls tell tell the ouput
pls tell the program as well as the output