Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

1. Character strings in C and C++ are implemented as arrays of char. These arrays can be initialized to string constants, as in char name [] = "freddie";

The array name will have eight elements, because all strings are terminated with a null character (zero), which is implicitly supplied by the system for string constants.

Arrays of strings in C and C++ can also be initialized with string literals. In this case, the array is one of pointers to characters. For example,

char *names [] = {"Bob", "Jake", "Darcie"};

This example illustrates the nature of character literals in C and C++. In the previous example of a string literal being used to initialize the char array name, the literal is taken to be a char array. But in the latter example (names), the literals are taken to be pointers to characters, so the array is an array of pointers to characters. For example, names[0] is a pointer to the letter 'B'in the literal character array that contains the characters 'B', 'o', 'b', and the null character.

In Java, similar syntax is used to define and initialize an array of references to String objects. For example,

String[] names = ["Bob", "Jake", "Darcie"];

From above it shows one way to create an array of strings in C or C++:

Char *name[] = {"Bob", "Jake", "Darcie"};

There is another way to get a similar effect, however:

Char *name[] [7] = {"Bob", "Jake", "Darcie"};

Compare these two techniques with respect to ease of use and efficiency.

2. a. Which class (es) in Java API represented associative array?

b. Which class(es) in the C++ standard library represent associative arrays?

3. Translate the following Ada record type into Java. Your translation should be as close to the original as possible.

type Employee_Name_Type is
record
    First: String(1..20);
    Middle: String(l..10);
    Last: String(1..20);
end record;

4. Suppose that L1 is the list ((A B) C D) and L2 is the list ((E) F). give the value of each of the following LISP expression:

1. (CONS (CAR L1) (LIST (CDR L2)))

2. (CONS (CAR (CDR L2)) (CAR L1))

3. (CDR ( CONS (CAR (CONS 'G L1)) ' (H))

4. (LIST (LIST (CAR L1) L2) 'G)

5.

a. Are the unions in Modula-2 considered to be "free unions"? Explain your answer.

b. type Shape is (Circle, Triangle, Rectangle);

type Colors is (Red, Green, Blue);

type Figure (Form : Shape) is

    record

Filled : Boolean;

Color : Colors;

case Form is

     when Circle =>

Diameter : Float;

     when Triangle =>

     Left_Side : Integer;

     Right_Side : Integer;

     Angle : Float;

   when Rectangle =>

Side_1 : Integer;

Side_2 : Integer;

end case;

  end record;

Translate the Ada variant record (above) to Modula-2.

6. a. what is the purpose of the restrict keyword in C99?

b. Give an example showing how restrict is used.

7. a. Give the minimum size of the following C++ structure, assuming that char and bool values occupy one byteintand float values occupy four bytes, double values occupy eight bytes, and pointers occupy four bytes.

struct s {

    char a;

    int b;

    bool *c;

    char d[5];

    union {

  int *e[3];

  float f;

  double g;

    };

};

b. Assuming that the structure has its minimum size, what is the offset of each member from the beginning of the structure? ( The offset of a will be 0, for example.) Include the offsets of ef, and g in your answer.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9482636

Have any Question?


Related Questions in Programming Language

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As