Question

In: Computer Science

Declare and initialize an array to store the course name or code.

Declare and initialize an array to store the course name or code.

Solutions

Expert Solution

Lets Assume We have Course Names as Maths , English Algorithm , Data Structures , COA

An array is a collection of items stored in contiguous memory location . All the items are of same data type such as integers or strings

we have Names of Course so Data Type used Will be Strings

Declare a array

String arr[10];

This statement means that arr is a array that contain 10 elements of String Data Type

To Declare and Initialize a Array we do

String Course_Names [] ={  "Maths" , "English" "Algorithm" , "Data Structures ", "COA"  };

In this we don't need to specify the Size we can simply Write the items in Curly Braces separated by commas to initialize the array .

This how you can declare and initialize a Array containing Course Names .

Note :--> Syntax may differ according to the programming language you are using . As you not mentioned any so I have Used Mostly used i.e. C++ . If u need in any other language just ask in comments

If u like the answer then Upvote it and have any doubt comment it


Related Solutions

Declare a string variable and initialize it with your first name ( in C++)
Declare a string variable and initialize it with your first name ( in C++)
Provide the code segment need to DECLARE an array of structures that could store information about a group of US Passports.
Provide the code segment need to DECLARE an array of structures that could store information about a group of US Passports. Do not write a program or worry about initializing the structure, all I am looking for is a set of structure types whose combined members would hold all the information found in a password, AND any supporting structures. Be careful on how you declare the members of a structure. Grading will be based on the flexibility of your design...
A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String...
A) Declare a String variable called myString0 and initialize it to "Java". B) Declare a String variable called myString1 and initialize it to "Programming". C) Declare a String variable called myString2 and initialize it to "Language". D) Print the concatenation of myString0 + " is a " + myString1 + " " + myString2 + ".". E) Print the sum of the lengths of myString1 and myString2 (must call the length() method). F) Print the 2nd, 4th, and 7th character...
a) Write C code initialize an array of ints to the last four digits of your...
a) Write C code initialize an array of ints to the last four digits of your phone number. Use a loop to add the digits. Calculate and display the average of the digits. b) Write C code using a struct to hold student information: integer id integer number of hours taken integer number of hours passed double gpa
For c++ Write the code to initialize an array such that each element gets two times...
For c++ Write the code to initialize an array such that each element gets two times the value of its index (e.g. 0, 2, 4, 6, …)
Write a program in c# that declare a variable and store user name jjohn in. Then,...
Write a program in c# that declare a variable and store user name jjohn in. Then, write a statement that will make your program display at the screen the content of that variable, followed by " I would like to know your height in centimeter. Please enter it:". Then, write a statement that will store the value entered by the user, allowing decimal numbers ie some precision, a fraction part. Finally, write statements (more than one can be needed) so...
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.
Provide code samples for the following in C#a. Declare a two-dimensional array of integers names...
Provide code samples for the following in C#a. Declare a two-dimensional array of integers names intArray17.b. Create a loop to calculate the sum of every element in the first column.c. Create a loop to calculate the sum of every element in the array.
In C# - Provide code samples for the following: Declare a two-dimensional array of integers names...
In C# - Provide code samples for the following: Declare a two-dimensional array of integers names intArray17. Create a loop to calculate the sum of every element in the first column. Create a loop to calculate the sum of every element in the array.
Write a class Roster that is identified by the course name, course code, number of credits,...
Write a class Roster that is identified by the course name, course code, number of credits, instructor name, and contains a list of students stored in an array. For now you can use stack allocated array of MAX_CAPACITY=10 (define MAX_CAPACITY as a macro in the .h file). Later we will make this array dynamic to allow it to grow. Provide necessary constructors, accessor functions for each member, and mutator functions for each member. Provide a function to add a student...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT