with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure factorial_ada is
n, i : Integer;
output : Integer := 1;
begin
Put_Line("Enter the number to be taken factorial of: ");
Get(n);
-- Begin Loop
for i in 2..n
loop
output := output * i;
end loop;
Put("Factorial of ");
Put(n);
Put(" is ");
Put(output);
end factorial_ada;
Run Code Online (Sandbox Code Playgroud)
我的代码可以编译并运行,但我收到一条警告,提示“变量“i”永远不会被读取,也永远不会被赋值”“for 循环隐式声明循环变量”“声明隐藏了在第 15 行声明的“i””
我该如何解决?
ada ×1