MABS Institution
11th Computer Science Monthly Test - 2 ( Arrays and Structures )-Aug 2020
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Write a note in getQ function.
-
What are the different ways to initialize the structure members?
-
Write about returning structures from functions.
-
Write a C++ program to accept and print your name?
-
Write a note on 2D array declaration.
-
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 a program to assign data to members of a structure variable and display the contents.
-
How to access members of a structure? Give example.
-
-
Write a user defined function to return the structure after accepting value through keyboard. The structure definition is as follows
struct Item{int item no;float price;}; -
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;
} -
Write a C++ program to read the marks of 10 students in an array and to find the average of all those marks.
-
Write the output of the following c++ program
#include
#include
#include
#include
using namespace std;
struct books {
char name[20], author[20];
} a[50];
int main()
{
clrscr();
cout<< "Details of Book No " << 1 << "\n";
cout << "------------------------\n";
cout << "Book Name :"<cout << "Book Author :"< cout << "\nDetails of Book No " << 2 << "\n";
cout << "------------------------\n";
cout << "Book Name :"<cout << "Book Author :" < cout << "\n\n";
cout << "================================================\n";
cout << " S.No\t| Book Name\t|author\n";
cout << "====================================================";
for (int i = 0; i < 2; i++) {
cout<< "\n " << i + 1 << "\t|" << a[i].name << "\t| " << a[i].author;
}
cout<< "\n=================================================";
return 0;
} -
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 returning structures from functions with an example.
-
Write a C++ Program to declare a structure book containing name and author as character array of 20 elements each and price as integer. Declare an array of book. Accept the name, author, price detail for each book. Define a user defined function to display the book details and calculate the total price. Return total price to the calling function.
-
Write a C++ program to perform addition of two matrices.
-
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;
}