Info
This question is closed. Reopen it to edit or answer.
HELP ME PLEASE!!!
2 views (last 30 days)
Show older comments
what is wrong this ?
clc;
clear;
A=(4,7,-3,5,6,12);
n=0;
p=0;
for i=1:length(A)
if A(i)<0
n=n+A(i);
else
p=p+A(i);
end
end
o=n/p;
fprintf('Pozitif Elemanların Toplamı : %g',p);
fprintf('Negatif Elemanların toplamı : %g',n);
fprintf('Oran : %g',o);
1 Comment
Are Mjaavatten
on 15 May 2020
Edited: Are Mjaavatten
on 15 May 2020
Use square brackets in the expression for A:
A=[4,7,-3,5,6,12];
And add a newline (\n) to the strings in fprintf:
fprintf('Pozitif Elemanların Toplamı : %g\n',p);
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!