Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can anyone help me on these 10 questions.
I will be really thankful.1) Which of the following two ways of declaring a structure and variable is correct:
(i)structPayInformation
{
float pay;
float benefits;
float deductions;
};
struct Employee
{
string name;
PayInformationpayInfo;
};
Employee emp; (ii)structEmployee
{
string name;
float pay;
float benefits;
float deductions;
};
Employee emp;a) (i)is correct, but (ii) is not.
b) both (i)and (ii) are correct.
c) both are correct, but (i)is more memory efficient.
d) (ii)is correct, but (i) is not.2) In solution (i)to question 1 above, which of the following is the correct way to access the data stored inpay?
a) Employee.payInfo.pay
b) Employee.PayInformation.pay
c) emp.payInfo.pay
d) emp.PayInformation.pay
e) emp.pay.3) Is the following way of declaring a struct variable student valid?
structstudentInfo
{
stringname;
floatGPA;
}student;
a) Yes
b) No
c) Maybe – it depends on the compiler.
4) For the following array declaration, which of the following accesses to elements in the array are valid?
int studentArray[100];
a) studentArray[0]
b) studentArray[100]
c) studentArray[50]
d) a, b, and c
e) both a and c
5) Which of the following are valid parameter passing mechanisms for arrays?
a) pass by value
b) pass by reference
c) a and b
d) None of the above
6) What is the difference between a two-dimensional array and two parallel arrays?
a) A two-dimensional array is used to represent a grid structure whereas two parallel arrays consist of two 1-dimensional arrays that are related to each other semantically
b) Both are the same, they are just different terminology for the same thing.
c) A two-dimensional array must contain the same data type in all of its elements, whereas each parallel array could contain a different type
d) Both a and c
e) None of the above7) Which of the following is the correct function prototype for a function that accepts a 2-dimensional integer array that is of size array[3][3]?
a) voidfunc(intarray[][3]);
b) voidfunc(intarray[3][]);
c) voidfunc(intarray[][]);
d) voidfunc(intarray[]);
The next three questions use the following definitions:
structstudentInfo
{
string firstName;
string lastName;
int projectMarks[5];
int hwMarks[4];
};
studentInfostudent[50];8) In order to search for a student whose first name is "John", which of the following algorithms should I use?
a) for(int i=0;iMAX_STUDENTS;i++)
if(student[i].firstName=="John")
cout"Studentisenrolled"endl;
cout"Studentisnotenrolled"endl;
b) boolflag=false;
for(int i=0;iMAX_STUDENTS;i++)
if(student[i].firstName=="John")
{
cout"Student is enrolled"endl;
flag=true;
}
if(flag==false)
cout"Studentisnotenrolled"endl;
c) for(inti=0;iMAX_STUDENTS;i++)
{
bool flag=false;
if(student[i].firstName=="John")
{
cout"Studentisenrolled"endl;
flag=true;
}
}
if(flag==false)
cout "Student is notenrolled"endl;
d) All of the above9) Which code will access the project marks of the 45th student in the class?
a) student[45].projectMarks[3]
b) student[44].projectMarks[3]
c) student[44].projectMarks[4]
d) studentInfo[44].projectMarks[3]10) What term is the best way to describe student above?
a) An array of structures
b) A structure containing arrays
c) An array of structures that has other arrays as elements of the structure
d) An array of an array of structures

Well normally I go by the rule of thumb not to post
homework on this site however someone else may
feel more inclined to help.

1.a
2.c
3.b
4.d
5.c
8.a
9.b
10.d
Now that I gave you a sense of false hope, pick your book up and actually try to solve these questions yourself. I will only assist when you prove that you tried to help yourself.Infinite Recursion

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |