0% found this document useful (0 votes)
32 views6 pages

11 CS CH 12

TN 11th computer science

Uploaded by

saravanan.c412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views6 pages

11 CS CH 12

TN 11th computer science

Uploaded by

saravanan.c412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CHAPTER 12

3 MARKS

3. 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;
}
ANSWER:
5 MARKS

2. Write a C++ program to add two distances using the following structure definition
struct Distance{
int feet;
float inch;
}d1 , d2, sum;

ANSWER:
3. Write the output of the following c++ program
#include<iostream>
#include<stdio.h>
#include <string.h>
#include<conio.h>
using namespace std;
struct books {
char name[20], author[20];
} a[2];
int main()
{ cout<< "Details of Book No " << 1 << "\n";
cout<< "------------------------\n";
cout<< "Book Name :"<<strcpy(a[0].name,"Programming ")<<endl;
cout<< "Book Author :"<<strcpy(a[0].author,"Dromy")<<endl;
cout<< "\nDetails of Book No " << 2 << "\n";
cout<< "------------------------\n";
cout<< "Book Name :"<<strcpy(a[1].name,"C++programming" )<<endl;
cout<< "Book Author :"<<strcpy(a[1].author,"BjarneStroustrup ")<<endl;
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;
}

ANSWER:
4. Write the output of the following c++ program
#include <iostream>
#include <string.h>
using namespace std;
struct student
{
introll_no;
char name[10];
long phone_number;
};
int main(){
student p1 = {1,"Brown",123443},p2;
p2.roll_no = 2;
strcpy(p2.name ,"Sam");
p2.phone_number = 1234567822;
cout<< "First Student" <<endl;
cout<< "roll no : " << p1.roll_no <<endl<< "name : " << p1.name <<endl;
cout<< "phone no : " << p1.phone_number <<endl;
cout<< "Second Student" <<endl;
cout<< "roll no : " << p2.roll_no <<endl<< "name : " << p2.name <<endl;
cout<< "phone no : " << p2.phone_number <<endl;
return 0;
}
ANSWER:
5. Debug the error in the following program
#include <istream.h>
structPersonRec
{
charlastName[10];
chaefirstName[10];
int age;
}
PersonRecPeopleArrayType[10];
void main()
{
PersonRecord people;
for (i = 0; i < 10; i++)
{
cout<<people.firstName<< ‘ ‘ <<people.lastName <<people.age;
}
for (int i = 0; i < 10; i++)
{
cout<< "Enter first name: "; cin<<peop[i].firstName;
cout<< "Enter last name: "; cin>>peop[i].lastName;
cout<< "Enter age: "; cin>> people[i].age;}
}
ANSWER:

You might also like