Q:

Write a function that will prompt the user separately for a filename and extension and will create and return a string with the form ‘filename.ext’

0

Write a function that will prompt the user separately for a filename and extension and will create and return a string with the form ‘filename.ext’. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

getfilename.m

function file = getfilename

% Prompts user for filename and extension and combines them

% Format of call: getfilename or getfilename()

% Returns one string of the form filename.ext

fname = input('Enter filename: ','s');

extension = input('Enter extension: ','s');

file = sprintf('%s.%s',fname,extension);

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now