How to call the second function inside the first function under the same file
Show older comments
% That is my code
% the expected result is :
Please enter the first user name: abby
Please enter the first user name: bob
The first user abby have 15 points
The second user bob have 15 points
% but there are bug on my code
function [p1,p2,Name1,Name2]= Playerpoint(point1,point2)
point1 = 10;
point2 = 11;
p1 = card1 + 5;
p2= card2 + 4;
Name1 = name1;
Name2 = name2;
fprintf("The first user %s has %d points\n",Name1,c1);
fprintf("The second user has %d points\n",Name2,c2);
end
function [name1,name2] = Playername(n1,n2)
name1 = n1;
name2 = n2;
end
% driver files
n1 = input('Please enter the first user name: ','s');
n2 = input('Please enter the second user name: ','s');
[name1,name2] = Playername(n1,n2);
card1 = 0;
card2 = 0;
[p1,p2,Name1,Name2]= Playerpoint(point1,pointt2);
% How to improve my code
% Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!