MABS Institution
11th Computer Science Monthly Test - 1 ( Arrays and Structures )-Aug 2020
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
What is wrong with the following C++ declarations?
A. struct point ( double x, y )
B. struct point { double x, double y };
C. struct point { double x; double y }
D. struct point { double x; double y; };
E. struct point { double x; double y; } -
Is the following snippet is fully correct. If not identify the error.
struct sum1 { int n1,n2;}s1;
struct sum2 {int n1,n2}s2;
cin>>s1.n1>>s1.n2;
s2 = s1; -
What is the size of the following highlighted variable in terms of byte if it is compiled in dev c++
struct A{ float f[3]; char ch[5];long double d;};
struct B{ A a; int arr[2][3];}b[3] -
Write a structure definition for the structure student containing examno, name and an array for storing five subject marks.
-
Write a program to assign data to members of a structure variable and display the contents.
-
Write a C++ program to accept and print your name?
-
The following code sums up the total of all students name starting with ‘S’ and display it.Fill in the blanks with required statements.
struct student {int exam no,lang,eng,phy,che,mat,csc,total;char name[15];};
int main()
{
student s[20];
for(int i = 0; i < 20; i ++)
{
…………………….. //accept student details
}
for(int i = 0; i < 20; i ++)
{
…………………….. //check for name starts with letter “S”
……………………. // display the detail of the checked name
}
return 0;
} -
Write the syntax and an example for structure.
-
Rewrite the following program after removing the syntactical error(s),if any.
Underline each correction.
struct movie
{
charm_name[10];
charm_lang[10];
float ticket cost = 50;};
Movie;
void main()
{
gets(m_name);
cin>>m_lang;
return 0;
} -
-
Explain one-dimenstional array with an example.
-
How to access members of a structure? Give example.
-
-
What is called nested structure. Give example
-
What is the difference among the following two programs?
(a) #include
struct point { double x; double y; };
int main() {
struct point test;
test.x = .25; test.y = .75;
cout<return 0;
}
(b) #include
188 struct { double x; double y; } Point;
int main(void) {
Point test={.25,.75};
return 0;
} -
What is row major order and column major order?
-
Write a C++ Program to Add two Complex Numbers by Passing Structure to a Function for the following structure definition
struct complex
{
float real;
float imag;
};
The prototype of the function is
complex add Complex Numbers(complex, complex); -
Explain array of structures with example
-
How call by reference is used to pass structure to a function .Give an Example
-
Write a C++ program to display the contents of the following structure definition.
-
Write a c++ program to declare and accept an array of professors. Display the details of the department = ”COMP.SCI” and the name of the professors start with ‘A’. The structure “college” should contain the following members.
prof_id as integer
name and Department as character array -
-
Explain call by value with respect to structure.
-
Write a C++ program to find whether a given string is a palindrome or 'not.
-
-
Explain returning structures from functions with an example.
-
Write C++ program to find transpose of a matrix.
-
Debug the error in the following program
#include< istrema.h >
structPersonRec
{
charlastName[10];
chaefirstName[10];
int age;
}
PersonRecPeopleArrayType[10];
voidLoadArray(PeopleRecpeop);
void main()
{
PersonRecord people;
for (i = 0; i < 10; i++)
{
cout<<
}
}
LoadArray(PersonRecpeop)
{
for (int i = 0; i < 10; i++)
{
cout << "Enter first name: ";
cin<cout << "Enter last name: ";
cin >> peop[i].lastName;
cout << "Enter age: ";
cin >> people[i].age;
}