Function Name: sepDigits
Inputs:
1. (double) A three-digit integer
Outputs:
1. (double) The hundreds-place digit of the input
2. (double) The tens-place digit of the input
3. (double) The ones-place digit of the input
Function Description:
This function will take in a three-digit integer (integer between
100 and 999 , inclusive)
and should return each digit as a separate number. For example, if
the input is 472 , the first
output would be 4 , the second would be 7 and the third would be 2
.
Notes:
● You only have to deal with three-digit positive integers.
● The mod() and floor() functions will do all the heavy
lifting.
CODE:
//it is a c program to seperate the digits of a 3 digit
number
#include<stdio.h>
void sepDigits(int n);
main(){
int n;
printf("\nEnter a 3 digit positive integer:");
scanf("%d",&n);
if(n<100||n>999){
printf("\nInvalid input... please
entere 3 digit positive integer");
}
else
sepDigits(n);
return 0;
}
void sepDigits(int n){
int r,i=0;
while(n!=0){
i++;
if(i==1){
r=n/100;
n=n%100;
printf("\n%d",r);
}
else if(i==2){
r=n/10;
n=n%10;
printf("\n%d",r);
}
else if(i==3){
r=n;
n=n%1;
printf("\n%d",r);
}
}
}
OUTPUT:
Function Name: sepDigits Inputs: 1. (double) A three-digit integer Outputs: 1. (double) The hundreds-place digit of...
Function Name: citizenWatch Inputs: Extra Credit 1. (double) T he current position of the hour hand 2. (double) T he current position of the minute hand 3. (double) A positive or negative number of minutes Outputs: 1. (double) The position of the hour hand after the specified time 2. (double) T he position of the minute hand after the specified time Background: The moment is finally here. You’ve been saving up your whole life and now you can finally afford...
MATLAB code help!
Function Name: chemTimer Inputs: 1. (double) The current position of the hour hand 2. (double) The current position of the minute hand 3. (double) A positive or negative number of minutes Outputs: 1. (double) The position of the hour hand after the specified time 2. (double) The position of the minute hand after the specified time Background: Oh no, you were running late to your Chem lab and completely forgot your reaction timer! It's a good thing...
Function Name: zoomZoom Inputs: 1. (double) An Nx5 array of scooters' speeds at various times 2. (double) The time at which you want to find the scooters' speeds Outputs: 1. (double) A 1x5 vector of scooters' speeds at the given time Background: Scooter go zoom zoom! Function Descripti on : You will be given an array with times in the first column, and speeds of different electric scooters in columns 2-5 that correspond to those times. Use spline interpolation or...
Function Name: runBabyRun Inputs: (double) Target distance to run before half-marathon (double) A 4x7 array of miles run each day in the month of February Outputs: (double) The most improvement made between consecutive days (logical) Whether you met your target distance for a single run (double) 1x4 vector of how many total miles you ran each week Function Description: With this New Year, you decide that you are actually going to run that half-marathon that has been on your calendar...
Function Name: fluxCapacitor Inputs: 1. (double) The current year 2. (double) Destination year 3. (double) Speed, in miles per hour Outputs: 1. (char) String stating whether you’re going back or forward into the future Background: Doc Brown has invited you on an adventure through time. As you two hop into the time-travelling Delorean, he inputs the current year and the destination year. As the Doc steps on the gas, he reminds you that you can’t interact with ANYONE, or you’ll...
Homework 02-Vectors, Strings, and Masking Function Name: forecast Inputs 1. (char) A character vector of the current forecast 2. (char) The word to be replaced 3. (char) The new word to put into the forecast Outputs 1. (char) The updated forecast description Banned Functions strrep), replace), regexprep() Background You have recently started your internship as a weather engineer at the local news station. Unhappy with how the curment forecasts are described as 'gloomy" and 'cold, you decide to use MATLAB...
Extra Credit Function Name: anagram Inputs: 1. 2. (char) String representing the anagram (char) Name of text file to write to Outputs: none File Outputs: 1. A text file containing all the permutations of the anagram Banned Functions: perms(), permute(), ipermute(), nchoosek (), combnk() Background: You guys know what do. You are professional MATLAB now, you got this! Function Description: Given a string, recursively determine all the unique ways to rearrange the letters. (i.e al the unique permutations). For example,...
matlab
Example: Function Name: battleFormation formation([3 5 11, formation1.txt) Inputs: (double) 1xN vector of the number of soldiers each line 2. (char)A file name, indluding extension, for the output file group number Formation1.txt: 1 Line 1 has the following line up: e 1 1 1 0 File Outputs: 21 Line 2 has the folloOwing line up: 1 1 1 1 1 1. A text file showing the soldiers formations 3 Line 3 has the following line up: e e 1...
Thank you for your help!
Homework 02 - Vectors, Strings, and Masking Function Name: badWeatherman Inputs: 1. (logical) Vector of suspect #1's answers to a lie detector (logical) Vector of suspect #2's answers to a lie detector (logical) Vector of suspect #3's answers to a lie detector (logical) Vector of suspect #4's answers to a lie detector 2" 3. 4. Outputs 1. (char) Sentence stating which suspect stole the fruit Banned Functions: isequal (, isequaln( Background Oh no, there has...