С++
#include <iostream>
using namespace std;
int main()
{
int S = 0;
int a = 1;
while(a <= 10)
S = S + a;
a = a + 1;
}
cout << S;
return 0;
55
Объяснение:
program z;
var S,a:integer;
begin
S:=0;
for a:=1 to 10 do S:=S+a;
write(S)
end.
С++
#include <iostream>
using namespace std;
int main()
{
int S = 0;
int a = 1;
while(a <= 10)
{
S = S + a;
a = a + 1;
}
cout << S;
return 0;
}
55
Объяснение:
program z;
var S,a:integer;
begin
S:=0;
for a:=1 to 10 do S:=S+a;
write(S)
end.