Answer:
See the explanation section
Explanation:
import java.util.*;
//The above statement is to import the Scanner and ArrayList class
public class StringSlicer {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter your string: ");
String inputString = scan.nextLine();
ArrayList<Character> stringList = new ArrayList<Character>();
for(int i = 0; i < inputString.length(); i++){
stringList.add(inputString.charAt(i));
}
for(Character letter: stringList){
System.out.println(letter);
}
}
}
Answer:
Go to explaination for the step by step answer.
Explanation:
a)Code
function[y]=operation(x) % this function takes x as input and returns y as output
y=(-0.2*x^3+7*x^2)*exp(-0.3*x)
end
% call this function in command widow by typing operation(value of x) like shown in figure in the first attachment.
b. write a code of above function in one script window and save the code with same name as name of function that is name of script should be saved as operation.Now copy paste the below code in new script window and run the code
clc
clear all
x=-2:.1:6
n=length(x)
for i=1:1:n
a=x(i)
y(i)=operation(a)
end
plot(y,x)
xlabel('X')
ylabel('Y')
Please kindly check attachment for pictorial answers that supports the code.
Answer:
Contact the company to find out what the problem is.
Explanation:
#include<stdio.h>
#include<stdlib.h>
int comment1(FILE *fp)
{
char ch;
int count=0;
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='\n')
{
return count;
}
count++;
}
return count;
}
int comment2(FILE *fp)
{
char ch;
int count=0;
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='*')
{
fscanf(fp,"%c",&ch);
if(ch=='/')
{
return count;
}
count++;
}
count++;
}
return 0;
}
int main()
{
printf("Enter the file name:");
char s[1000],ch,ch1;
scanf("%s",s);
FILE*fp;
fp = fopen(s,"r");
int count=0;
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='\"')
{
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='\"')
{
break;
}
if(ch=='\\')
{
fscanf(fp,"%c",&ch);
}
}
}
else if(ch=='/')
{
fscanf(fp,"%c",&ch);
if(ch=='/')
{
count += comment1(fp);
}
else if(ch=='*')
{
count += comment2(fp);
}
}
}
printf("%d\n",count);
return 0;
}