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...
C Programming:- What is the type of the variable x? uint8_t *x[256]; (Do not use spaces...
C Programming:- What is the type of the variable x? uint8_t *x[256]; (Do not use spaces in your answer) What type does the variable x decay to when used in an expression? uint8_t *x[256] (Do not use spaces in your answer) Consider the following function whose purpose is to return an array of 3 strings that are initialized to the strings in the character arrays s1, s2, and s3: #include <string.h> #include <stdlib.h> char** stringstoarray(char* s1, char* s2, char* s3)...
The code is in C programming language pls convert it into python. Thanks. Program --> #include...
The code is in C programming language pls convert it into python. Thanks. Program --> #include <stdio.h> #include <stdlib.h> void main() { //declare variables FILE *fileptr; char filename[15]; char charRead; char filedata[200],searchString[50]; int i=0,j=0,countNoOfWord=0,count=0; //enter the filename to be opened printf("Enter the filename to be opened \n"); scanf("%s", filename); /* open the file for reading */ fileptr = fopen(filename, "r"); //check file exit if (fileptr == NULL) { printf("Cannot open file \n"); exit(0); } charRead = fgetc(fileptr); //read the string...
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...
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:...
1. The data type that size_t represents is implementation dependent. Which are the only data types...
1. The data type that size_t represents is implementation dependent. Which are the only data types permitted? (Note 2.12) A. signed char, short, int, long, long long B. unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long C. float, double, long double D. char, unsigned short, unsigned int, unsigned long, unsigned long long E. any arithmetic data type
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT