How do i write algorithms

7 ビュー (過去 30 日間)
Antwone Goodwyn
Antwone Goodwyn 2019 年 4 月 29 日
コメント済み: Walter Roberson 2019 年 4 月 30 日
Develop M-file that can do followings
- Ask you starting and final number to add up (e.g., ni=0, nf=300)
- Display the total of the numbers (e.g., sum=0+1+2+....+300)
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 29 日
  • disp()
  • for
  • input()
  • plus()

サインインしてコメントする。

採用された回答

Raj
Raj 2019 年 4 月 29 日
Many ways of doing this problem. Below is one way:
ni=input('Enter initial value:');
nf=input('Enter final value:');
A=zeros(nf-ni,1);
A(1)=ni;
for i=2:size(A)+1
A(i)=A(i-1)+1;
end
Sum=sum(A)
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 30 日
We do not recommend posting complete solutions to homework problems.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by