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
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:...
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...
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...