Question

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:

Empoyee[] emp=new Employee[20];

Employee[20] emp;

Employee emp[20];

Question 3

You cannot use the reference ‘&’ operator with a structure.

Question 3 options:

True
False

Question 4

You cannot nest structures.

Question 4 options:

True
False

Question 5

A structure is useful when the program needs to store different values of different types in a single collection.

Question 5 options:

True
False

Question 6  

  1. Given the code below, which variable is not initialized as a variable of CityInfo

struct CityInfo

{

string cityName;

string state;

long population;

int distance;

};

Question 6 options:

CityInfo location = {"Asheville", "NC};

CityInfo location = {"Asheville", "NC", 50000, 28};

CityInfo location = {"Asheville", "NC", , 28};

CityInfo location = {"Asheville"};

Question 7

What would be printed from the following C++ program?

#include <iostream>

#include <string>

using namespace std;

struct Point

{

int x;

int y;

};

void makeTriangle(Point p[]);

int main()

{

Point p[3];

int i;

makeTriangle(p);

cout<<"The triangle consists of the following coordinates:\n";

for(i=0 ;i<3;i++)

cout<<"("<<p[i].x<<","<<p[i].y<<")"<<"\n"; ;

return 0;

}

void makeTriangle(Point p[]){

p[0].x = 200;

p[0].y = 20;

p[1].x = 150;

p[1].y = 100;

p[2].x = 300;

p[2].y = 100;

}

Question 8

In C++, we can declare a structure using "structure" keyword.

Question 8 options:

True
False

Question 9

What would be printed from the following C++ program?

#include <iostream>
#include <string>
using namespace std;

void printinfo(int);
void printinfo(string);

struct student //define structure student
{//variables

int id;
string name;

};
int main()
{


student st; //structure object
st.id = 100; //assign 100 to student id
st.name = "Sok";//assign Sok to student name
//output student information
printinfo(st.id);
printinfo(st.name);;
return 0;


}

void printinfo(int id){
cout<<id<<"\n";
}


void printinfo(string name)
{
cout<<name<<"\n";
}

Question 10

What would be printed from the following C++ program?

#include<iostream>

using namespace std;

struct Fract

{

int nomi;

int deno;

};

Fract sum(Fract,Fract);

int main()

{

Fract f1={1, 2};/* 1/2 */

Fract f2 ={2, 5};/* 2/5 */

Fract result = sum(f1, f2);//sum the fractions

cout<<"Result="<<result.nomi<<"/"<<result.deno; //display the result

return 0;

}

Fract sum(Fract f1, Fract f2)

{

Fract result={(f1.nomi * f2.deno) + (f2.nomi * f1.deno), f1.deno * f2.deno};

return result;

}

Homework Answers

Answer #1

Answer 1:What value a variable will hold?
data type can't decide what values it will hold.. it only decide what type of
values it will hold
Answer 2: Employee[20] emp;
[] should come after variable
Answer 3:False
we can use reference for structue to avoid large data copy
Answer 4:False
we can have nested structures

Answer 5:true
structue is collection of different data types

As per policy we can answer 1 question per post. Please post the remianing questions as separate post.Thanks

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
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
How to stop the program from exiting after display detail. When there is food detail, it...
How to stop the program from exiting after display detail. When there is food detail, it will display and exit the program. What can i do to make it not exit the program and back to main menu. #include <iostream> #include <iomanip> #include<string.h> using namespace std; struct food{ int order_id; string food_code,flavor,customer_id; string address,name; int weight,unit_price,qty,contact_number; struct food *next; };    class Foodsystem{ food *head,*temp,*temp2,*end; static int id;    public: Foodsystem(){ head=NULL;end=NULL;} void Place_Order(); void View_food_details(); void Modify_food_details(); void Delete_food_details();...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are pointers or constant pointers. Directions: Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS = 3; // may only be declared within the main function string students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Be sure to compile using g++ -std=c++11 helpWithGradesPtr.cpp Write a C++ program to run a menu-driven program with the...
Strings The example program below, with a few notes following, shows how strings work in C++....
Strings The example program below, with a few notes following, shows how strings work in C++. Example 1: #include <iostream> using namespace std; int main() { string s="eggplant"; string t="okra"; cout<<s[2]<<endl; cout<< s.length()<<endl; ​//prints 8 cout<<s.substr(1,4)<<endl; ​//prints ggpl...kind of like a slice, but the second num is the length of the piece cout<<s+t<<endl; //concatenates: prints eggplantokra cout<<s+"a"<<endl; cout<<s.append("a")<<endl; ​//prints eggplanta: see Note 1 below //cout<<s.append(t[1])<<endl; ​//an error; see Note 1 cout<<s.append(t.substr(1,1))<<endl; ​//prints eggplantak; see Note 1 cout<<s.find("gg")<<endl; if (s.find("gg")!=-1) cout<<"found...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template <class ItemType> class QueueADT { public:        // Action responsibilities        virtual void resetQueue() = 0;           // Reset the queue to an empty queue.           // Post: Queue is empty.        virtual void add(const ItemType& newItem) = 0;           // Function to add newItem to the queue.           // Pre: The queue exists and is not full.          ...
IntList Lab Specifications You are required to come up with a single header file (IntList.h) that...
IntList Lab Specifications You are required to come up with a single header file (IntList.h) that declares and implements the IntNode class (just copy it exactly as it is below) as well as declares the IntList Class interface only. You are also required to come up with a separate implementation file (IntList.cpp) that implements the member functions of the IntList class. While developing your IntList class you must write your own test harness (within a file named main.cpp). Never implement...