Написать программу ** языке TurboBasic

0 голосов
35 просмотров

Написать программу на языке TurboBasic


image

Информатика (30 баллов) | 35 просмотров
Дан 1 ответ
0 голосов

' Basic

' For ... Next
dim yi as integer
dim n as integer
dim z as double
dim sum as double
dim zi as double
  sum = 0
  print "Введите n: "
  input n
for yi = 1 to n
    if ((yi > 15) or (yi < 0)) then
      z = 2
    else
      z = yi
    end if 
    zi = (sqr(z)-z)*(sqr(z)-z)
    sum = sum + zi
next
  print "Сумма = ", sum;

'-----------------------------------------------------------

' While Wend
dim yi as integer
dim n as integer
dim z as double
dim sum as double
dim zi as double
  sum = 0
  yi = -1
  print "Введите n: "
  input n
while (yi < n)
    if ((yi > 15) or (yi < 0)) then
      z = 2
    else
      z = yi
    end if
    zi = (sqr(z)-z)*(sqr(z)-z)
    sum = sum + zi
    yi = yi + 1
wend
  print "Сумма =", sum;

(9.4k баллов)