Question

In the following C code, Which variable if NOT of primitive data type? A. a B....

  1. In the following C code, Which variable if NOT of primitive data type?
    A. a
    B. b
    C. c
    D. d
int a = 10;
double b = 20.0;
float c = false;
char d[5] =  "Hello"; // here we define a string
  1. In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined.
    A. True
    B. False

  2. In C# programming language, the enum variables are NOT coerced to int. The following C# code is invalid.
    A. True
    B. False

public enum Season
{
    Spring,
    Summer,
    Autumn,
    Winter
}

public class EnumConversionExample
{
    public static void Main()
    {
        Season a = Season.Autumn;
        int b = a + 1;
    }
}
  1. In the following C++ code, the new operator dynamically creates an array with a fixed length on the heap, this is called a ___ array.
    A. static
    B. fixed stack-dynamic
    C. fixed heap-dynamic
    D. heap-dynamic arraybr>
//filename demo.cpp

int* p = new int[100];

  1. Arrays can only contain elements of the same data type, while records can contain elements of different data types.
    A. True
    B. False

  2. In some programming languages, the two-dimensional arrays are implemented column by column (column-major order), What will be the memory block of the two-dimensional array-like?
    A. A
    B. B

  1. In the following python code, you can use an index 0 to access the name in an associative array.
    A. True
    B. False
// filename: demo.py

student1 = {"name": "John doe", "gender": "M", "age": 20}

student1[0]
  1. What problem(s) the following code will cause?
    A. dangling pointers
    B. lost dynamic-heap variable
    C. both
    D. neither
// filename: demo.c

int num1 = 10;
int num2 = 20;
int* p1 = &num1; // & is called address of operator, which returns the address of a variable
int* p2 = &num2;
p2 = p1;
  1. The type checking must be static if the type binding must be static.
    A. True
    B. False

  2. Two data types have the structure type equivalence if They are built in exactly the same way using the same type constructors from the same simple types, even the variable names and the order of the variables must be the same. The two data types Rec1 and Rec2 defined in the following code are structurally equivalent.
    A. True
    B. False

struct Rec1{
  char x;
  int y;
  char z[10];
};

struct Rec1{
  int y;
  char x;
  char z[10];
};

Homework Answers

Answer #1

char d[5]="Hello"

cannot define as primitive data type if use String there

because:-

String is non primitive data type

False

Because:

Dynamic Length Strings: Allows strings various length with no maximum. Requires the overhead of dynamic storage allocation and deallocation but provides flexibility. Ex: Perl and JavaScript

TRUE

code is invalid

because:-

we cannot explicitly cast season

C. fixed heap-dynamic

because :-

dynamic array store in heap area

TRUE

because:-

array can contain same data type where are records contain different data types

In some programming languages, the two-dimensional arrays are implemented column by column (column-major order), What will be the memory block of the two-dimensional array-like?

Answer:-
A. A

False:-

We cannot access using Student[0]

lost dynamic-heap variable

because p1 value assigning to p2

The type checking must be static if the type binding must be static.
Answer:-
B. False

because:- the tye checking must be static if the binding must be "dynamic"

A. True

because they are equal

Know the answer?
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
Similar Questions
For the following code in C, I want a function that can find "america" from the...
For the following code in C, I want a function that can find "america" from the char array, and print "america is on the list" else "america is not on the list" (Is case sensitive). I also want a function to free the memory at the end of the program. #include <stdio.h> #include <stdlib.h> struct Node { void *data; struct Node *next; }; struct List { struct Node *head; }; static inline void initialize(struct List *list) { list->head = 0;...
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
Create a program which uses each struct declared in problem 1 and accesses each member of...
Create a program which uses each struct declared in problem 1 and accesses each member of each struct. (a) Create a variable using each struct and initialize it with some mock data of your choosing. (b) Print the members of each struct separated by a newline. (c) Modify each member of each struct to something different. (d) Print all members again. Save your code as prob2.c. This is Problem 1: struct ProductData {     int ID;     char Name[50];     float Price;     int...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++ 11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume First array 04 Second array Result array that one array doesn’t contain two copies of...
can someone edit my c++ code where it will output to a file. I am currently...
can someone edit my c++ code where it will output to a file. I am currently using xcode. #include <iostream> #include <cctype> #include <cstring> #include <fstream> using namespace std; bool inputNum(int [],int&,istream&); void multiply(int[],int,int[],int,int[],int&); void print(int[],int,int,int); int main() {ifstream input; int num1[35],num2[35],len1,len2,num3[60],len3=10,i; input.open("multiplyV2.txt"); //open file if(input.fail()) //is it ok? { cout<<"file did not open please check it\n"; system("pause"); return 1; }    while(inputNum(num1,len1,input)) {inputNum(num2,len2,input); multiply(num1,len1,num2,len2,num3,len3); print(num1,len1,len3,1); print(num2,len2,len3,2); for(i=0;i<len3;i++) cout<<"-"; cout<<endl; print(num3,len3,len3,1); //cout<<len1<<" "<<len2<<" "<<len3<<endl; cout<<endl;    } system("pause"); } void...
Answer question for C# 1 of 10 When items are added or removed, a list resizes...
Answer question for C# 1 of 10 When items are added or removed, a list resizes itself. True False Question 2 of 10 What happens when you assign one list to another using the assignment operator? An error message generates. Elements copy to new memory locations. Both lists become value-type data elements. Both lists reference the same memory locations. Question 3 of 10 Which of the following is a valid example of calling a method and sending it an array...
Please create an array of Leg objects, one constructor that takes three parameters as constant C...
Please create an array of Leg objects, one constructor that takes three parameters as constant C string, and one number representing the distance in miles between the two cities Write a code block to create a static array (that is, not dynamic and not a vector) of 3 Leg objects using city names of your choosing. That's THREE objects, each created using THREE parameters. For example, the Leg class declaration looked like, class Leg { const char* const startCity; const...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
JAVA please Arrays are a very powerful data structure with which you must become very familiar....
JAVA please Arrays are a very powerful data structure with which you must become very familiar. Arrays hold more than one object. The objects must be of the same type. If the array is an integer array then all the objects in the array must be integers. The object in the array is associated with an integer index which can be used to locate the object. The first object of the array has index 0. There are many problems where...
1. Please write the following in C++ also please show all output code and comment on...
1. Please write the following in C++ also please show all output code and comment on code. 2. Also, use CPPUnitLite to write all test and show outputs for each test. Write CppUnitLite tests to verify correct behavior for all the exercises. The modifications are aimed at making the exercises more conducive to unit tests. Write a function that swaps (exchanges the values of two integers). Use int* as the argument type. Write a second swap function using a reference...