Question

I have questions declare of array several form. Question . Write array declarations for the following...

I have questions declare of array several form.

Question .

Write array declarations for the following data:

i) x = An array of 15 double type numbers
ii) ? = [ 1 0 0 2 0 0 3 0 0]
iii) word = 10 words of at most 9 characters each

iv) Z = A 5 × 10 matrix of all zeroes

THX!

language is C

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. double x [14];

As array indexing starts from 0. So, taking 14 as the size of the array to store 15 elements.

2. int M[] = {1,0,0,2,0,0,3,0,0};

An integer array M is declared.

  1. char arr[10][9] =

                { "one",

                "two",

                "three",

                "four",

                "five",

                "six",

                "seven",

                "eight",

                "nine",

                "ten"

                };

A two-dimensional character array is declared where first dimension is for array size and second dimension is for length of string.

  1. int Z[5][10] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

A two-dimensional integer array is declared where the first dimension is for row size and the second dimension is for column size.

Add a comment
Know the answer?
Add Answer to:
I have questions declare of array several form. Question . Write array declarations for the following...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • 1. Declare an array of five integers named boxes. 2. what do you type to access...

    1. Declare an array of five integers named boxes. 2. what do you type to access the third element in the boxes array? 3. what do you type to assign the number 10 to the 5th element in the boxes array? 4. Declare an array named cartons that contains these values: 4.2 , 3.1, 6.8 5. what is the subscript value of 6.8 in the cartons array? 6. what will this program output if is in a complete program? cout<<...

  • Description: Write a complete C++ program that will do the following: 1. Declare an array of...

    Description: Write a complete C++ program that will do the following: 1. Declare an array of 30 elements 2. Set the array to random numbers between 0 to 100 inclusive. Don't seed the random number generator. 3. Output the array. 4. Sort the array in ascending order using the selection sort. 5. Output the sorted array. Required IO: Array by F. Last Original: 1 5 ... 2 10 + Sorted: 1 2 ... 5 10 ( +

  • Write a program demonstrating your understanding of arrays: Declare, initialize and printout the contents of the...

    Write a program demonstrating your understanding of arrays: Declare, initialize and printout the contents of the following: 1. an integer array with 100 random values in it (select your random numbers from this domain: [1,1000])        To instantiate a random number object put the following line in the Main() method at the beginning of the function:                Random rndm = new Random();   // thanks Nicolas and Alexander!!         To ask for a random number from the random number object put...

  • C++ is fhe language 3. a) Write down answer for each of the following i) Give...

    C++ is fhe language 3. a) Write down answer for each of the following i) Give example of any string constant: ii) What is the relational operator to check equality for two variables? iii) Character constant for putting a tab: iv) Key word for setting width of an output: v) Function for finding the length of a string str1: b) Evaluate each of the following arithmetic or logical expression: i) Given x = 4, y = 8, z = 3...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • write a program which include a class containing an array of words (strings).The program will search...

    write a program which include a class containing an array of words (strings).The program will search the array for a specific word. if it finds the word:it will return a true value.if the array does not contain the word. it will return a false value. enhancements: make the array off words dynamic, so that the use is prompter to enter the list of words. make the word searcher for dynamic, so that a different word can be searched for each...

  • I dont understand how to solve these type of questions. Q2. (25 marks) Write a C++...

    I dont understand how to solve these type of questions. Q2. (25 marks) Write a C++ program that takes a sentence as input (type string) and returns what follows. Structure your program using functions. 1. The number of characters 2. The number of words in the sentence 3. The number of proper words (any word that starts with a capital letter except the first word) 4. The number of words that contain two consecutive letters (e.g., "letter”)

  • Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in...

    Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in one of two ways. In one method, the array elements are placed in a list enclosed in curly braces after the array name definition. For example, the code below creates an array of ints with 3 elements: 1, 2 and 3. int[] a = {1, 2, 3, 4}; We can also initialize an array with a new construct, indicating how many elements we want...

  • Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized...

    Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT