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
ADVERTISEMENT
##### Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

ADVERTISEMENT