#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> x;
int n, inp;
cin >> n; // number of input
while(n--){
cin >> inp; // give
input
x.push_back(inp);
}
cout << " first element : " << x[0]
<< endl;
cout << " last element : " << x[x.size()
-1] ;
return 0;
}

# Create vector x with values 12, 32, 33, 44
x <- c(12, 32, 33, 44)
# Extract first and last elements
first_element <- x[1]
last_element <- x[length(x)]
# Print results
cat("Vector x:", x, "\n")
cat("First element:", first_element, "\n")
cat("Last element:", last_element, "\n")Vector x: 12 32 33 44
First element: 12
Last element: 44
Task 1 Please generate a vector of the following values: 12,32,33,44 and assign this vector to...
We have a list x = [1,2,3,4,5]. Please write codes to generate in Python: 1. the first element of x 2. the first three element of x 3. the last three element of x. (use the format on page 8 of the slide)
Matlab code assistance - task 1 and 6 I think I am right and just need to be pointed in the right direction if I should change anything %% Task 1 % create the 3 row vectors shown in Ex 8 using 3 different approaches Ex 8 = using the colon operator and also the linspace function, create the following row vectors -5 -4 -3 -2 -1 5 7 9 8 6 4 % 1. list the values explicitly (square...
2.6) Mathlab Exercise 1. Create a row vector v with values (1, 2, 3, 5, 11, 7, 13). 2. Change the value of the 5th and the 6th element of the v to 7 and 11 respectively. Try doing this with only one command as well. 3. Create a vector Five5 out of all multiples of 5 that fall between 34 and 637. By the way, how many are they? (Tip: look up the command ”length” in help.) 4. Double...
solve using scilab
show codes
Task 1 Generate a time vector (series) “t' which contains the number 0 to 9. i.e 0 st 10 with a step size of 1 Repeat the experiment with a step size of 0.01. (1.5 marks) 57%, 13:23 Task 2.2 Let X(t) = A sin(217ft) where A= Amplitude Frequency E-Time a) Create the signals X (t) = A, sin(26ft) and X (t) = A, sin(271f_t) where A, = 2, A, = 4, f = 20,...
solve using scilab and show codes
Task 1 Generate a time vector (series) 't' which contains the number 0 to 9. i.e 0 st 10 with a step size of 1 . Repeat the experiment with a step size of 0.01. (1.5 marks)
TASK 1: [20] • Write a little program that creates a vector array of type doubles with 10 members (0…9) • Use a for loop to store the values i^2 in the vector for each index i • Also write code to display the content of the vector• The output should be: 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 • Instead of using array access, try to use push_back, pop_back, etc. also, i.e. try being
dynamic. TASK...
Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...
Create an array of size 10 Assign values to the array Print the array Swap the first and last elements in the array Print the array Shift all elements by one to the right Print the array Replace even elements with 0 Replace each element except the first and last by the larger of its two neighbors Print the array
solve it by using matlab
Question 2) (2.5 points) Examine the following trigonometric identity: sin'(x) = (3 sin(a) – sin(3.c)) Verify that this identity is valid. To do so, define a variable x as x = 84 (in degrees!). Compute the left and right sides of the identity and assign them to variables p2left and p2right. Because x is in degrees, make sure you are using the correct trig function! Use the help function if you are unsure. Question 1)...
IN JAVA Task: Find the maximum value and minimum value in milesTracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 Given Code: import java.util.Scanner; public class ArraysKeyValue { public static void main (String [] args) { final int NUM_ROWS = 2; final int NUM_COLS = 2; int [][] milesTracker = new int[NUM_ROWS][NUM_COLS]; int i = 0; int j = 0; int maxMiles = 0;...