Question

In: Computer Science

Name the data type,value type and array size / name of the followings. 1) 20.4 2)...

Name the data type,value type and array size / name of the followings.

1) 20.4

2) a=5

3) [2 3 8]

4) ' 7 '

5) ' abc'

6) pi

7) b=true

8) 20+2i

9) [ 'a' 'b' 'c' ]

10) [ 'a' ; 'b' ]

11) [1 2 ;4 5;7 8]

12) [20,21,22,23]

13) c= [a;b]

14) c= [b:a]

15) d=[b:a ; b:a]

16) magic(3)

17 uint8(20)

18) int8(d)

Solutions

Expert Solution

1) 20.4 - It simply defines a Floating Point value.

2) a=5- It declares an integer value as 5 so that it can be used further for another calculations like shown below

3) [2 3 8] It simply creates a 1-d array having 1 row and 3 column i.e 1x3 Array with values- 2,3,8

4) ' 7 ' - Character

Since now it is written in between single quotes now it is not an integer now it has been defined as a character, That's why if we add directly 7+2 we get 7 but when we add '7' + '2' it adds ASCII values of character 7 and 2 i.e 55 ad 50 and gives us 105

5) ' abc'- Chacter Array with 3 elements, Basically charcter array is nothing but just a sequence of characters

6) pi - It is a function which gives a long floating point number which gives a nearest value of π.

7) b=true- It is used for boolean values or logical value,Where True gives logical value 1 and false gives value 0.

8) 20+2i- Complex Number

9) [ 'a' 'b' 'c' ]- It simply creates an array of characters.

10) [ 'a' ; 'b' ]- Now Here since we placed ; between two characters it will create them as two rows hence it created 2x1 array.

11) [1 2 ;4 5;7 8]- It Creates a 2D Array with 3 rows and 2 columns, in which elements of each row are entered one by one separated by semicolon ";".

12) [20,21,22,23]- It simply creates a 1-d array having 1 row and 3 column i.e 1x3 Array with values- 20,22,22,23

13) c= [a;b]- Now if a=2 and b=5, this instruction will create 2x1 array

14) c= [b:a]- Same here it will just create array with b in first row and a in second one.

15) d=[b:a ; b:a]- It gives a 2x0 empty double matrix.

16) magic(3)- Magic command creates a magic square array of size which is passed, in which sum of elements in a row or column or diagonally is same

So for magic(3) it creates a magic square array of size is (3,3)

Row-wise row 8+1+6=15 Column Wise 8+3+4=15 Diagonal 8+5+2=15

3+5+7=15 1+5+9=15 6+5+4=15

4+9+2=15 6+7+2=15

17 uint8(20)- It converts integer to 8 bit unsigned integer.

18) int8(d)- It gives Integer to 8 bit signed integer.


Related Solutions

Please enter a seed: 1 Please enter the size of the array: 1 Array size must...
Please enter a seed: 1 Please enter the size of the array: 1 Array size must be greater than 1. Please reenter: 0 Array size must be greater than 1. Please reenter: -1 Array size must be greater than 1. Please reenter: 12 Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element...
c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
1. What is the structure data type in C? 2. What is the value ranges of...
1. What is the structure data type in C? 2. What is the value ranges of data type of unsigned char, unsigned short, respectively? 3. How many regular resisters are in this X-CPU? 4. How does the X-CPU access the memory? 5. What is the maximum memory address? 6. Which statements in the code is to increase the PC value? 7. What is the minimal cycle number that is just needed to print “Hello world!” 4 times? 8. what is...
1) Load the data from lab6_precipitation.csv into a numpy array; 2) Make a numpy array with...
1) Load the data from lab6_precipitation.csv into a numpy array; 2) Make a numpy array with the years 1916-2016 and dtype=int; 3) Make a numpy array with the months 1-12 and dtype=int; 4) Print out the shape of the data array and the lengths of the years and month array. If the length of your year array does not equal the number of rows in your data array, or the length of your months array does not equal the number...
1) Write a function searchValue that accepts an array of integers, the size of the array,...
1) Write a function searchValue that accepts an array of integers, the size of the array, and an integer. Find the last occurrence of the integer passed in as an input argument in the array. Return the index of the last occurrence of the value. If the value is not found, return a -1 2) Write the line of code to call the previous function assuming you have an array vec with length n, and are looking for the number...
//   Given an array of size 9, with the values of 1-9, determine if the array...
//   Given an array of size 9, with the values of 1-9, determine if the array //   is valid or not. //   Display a message stating the row is VALId, or state its INVALID and what //   was the index number that determined the data invalid. // //   Use this java code as a start of your code. //   Test the array data by changing the values. //============================================================================= import java.util.*;    public class Soduko_ValidateRow    { public static void main(String...
1) Submit your completed dynamic array with template/generic data type (DArray.java) implementation. 2) Complete the template...
1) Submit your completed dynamic array with template/generic data type (DArray.java) implementation. 2) Complete the template DArray (if you have not done so) and this attached Iterator class. Make sure to document and test your code thoroughly. import java.util.Arrays; public class DArray { private final double GROW_FACTOR = 0.5;// array size growing rate //attributes private int size; private int buffer[]; //the actual array //constructors public DArray() { this.size=10; } public DArray(int size) throws Exception { if(size < 0) { throw...
Write a java code segment to declare an array of size 10 of type String and...
Write a java code segment to declare an array of size 10 of type String and read data for them from a file, prompt user for the file name. Data is stored in a file with 1 string per line.
Given an array of Student type and size 10, create a linked list of students by...
Given an array of Student type and size 10, create a linked list of students by linking students with an odd index first and then linking students with an even index. Write a loop to print out the students in the linked list #include<iostream> #include<string> #include<fstream> using namespace std; const int NUM = 10; struct Student{ string fName; string lName; Student * next; }; int main() {        Student stuArr[NUM];        ifstream myfile;        myfile.open("Test.txt");        for(int i = 0;...
Given an array of Student type and size 10, create a linked list of students by...
Given an array of Student type and size 10, create a linked list of students by linking students with an odd index first and then linking students with an even index. Write a loop to print out the students in the linked list. #include #include #include using namespace std; const int NUM = 10; struct Student{ string fName; string lName; Student * next; }; int main() { Student stuArr[NUM]; ifstream myfile; myfile.open("Test.txt"); for(int i = 0; i < NUM; i++)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT