0% found this document useful (0 votes)
3 views13 pages

Assignment 2

The document outlines the definitions of classes for students, teachers, TVs, and cars, along with functions for reading and printing their details. It also includes various code snippets demonstrating how to filter and print student information based on specific conditions. Additionally, it presents a bonus question about calculating and printing students with marks above the average.

Uploaded by

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

Assignment 2

The document outlines the definitions of classes for students, teachers, TVs, and cars, along with functions for reading and printing their details. It also includes various code snippets demonstrating how to filter and print student information based on specific conditions. Additionally, it presents a bonus question about calculating and printing students with marks above the average.

Uploaded by

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

Assignment

Classes
Define class of a student having following attributes.
Roll number,name,father name, CGPA
Class student
{

};

Define class of a teacher having following attributes.


Department,name,father name, Experience
Class Teacher
{

};
Define class of a tv having following attributes.
Company name,Price,size
Class tv
{

};

Define class of a car having following attributes.


Company name,Price,model number
Class tv
{

};
Write the definition of following functions.

read_student( )
{

}
print_student( )
{

read_n_student( )
{

}
print_n_student( )
{

}
Write the definition of following functions.

read_teacher( )
{

}
print_teacher( )
{

read_n_teacher( )
{

}
print_n_teacher( )
{

}
Write what this code will do.

class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
print_student(arr[index]);
}

2.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].age>5)
{
print_student(arr[index]);
}
}

}
3.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].age>5)
{
print_student(arr[index]);
}
}

4.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].age%5==0)
{
print_student(arr[index]);
}
}

}
5.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].age%5==0)
{
print_student(arr[index]);
}
}

}
6.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].name[0]==’a’)
{
print_student(arr[index]);
}
}

}
7.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
If(arr[index].name[1]==’d’)
{
print_student(arr[index]);
}
}

}
8.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(l1>3)
{
print_student(arr[index]);
}
}

}
9.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(l1>3&&l1<=8)
{
print_student(arr[index]);
}
}

}
10.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(l1>3&&arr[index].name[0]==’a’)
{
print_student(arr[index]);
}
}

}
11.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-1]==’a’)
{
print_student(arr[index]);
}
}

12.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-1]==’b’)
{
print_student(arr[index]);
}
}

}
13.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-1]==’a’)
{
print_student(arr[index]);
}
}

14.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-2]==’b’)
{
print_student(arr[index]);
}
}

}
15.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-1]==’a’&&arr[index].age%2==0)
{
print_student(arr[index]);
}
}

16.
class student
{
int age;
char name[20];

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(index=0;index<5;index++)
{
int l1=strlen(&arr[index].name[0])
if(arr[index].name[l1-1]==’z’||arr[index].age>20)
{
print_student(arr[index]);
}
}

}
Write conditions in the program, as given below
1. Print details of all students having marks greater than 50
2. Print details of all students having marks less than 30
3. Print details of all students having age between 18 and 22
4. Print details of all students whose name length is between 5 and 10.
5. Print details of all students having name started with ‘a’ and whose name ends with ‘i’
6. Print details of all students having name started with ‘b’ and whose name ends with ‘y’

class student
{
int age;
char name[20];
int marks;

};
void main()
{
class student arr[10];

read_n_students(&arr[0],5);

for(int index=0;index<5;index++)
{

if( )
{
print_student(arr[index]);
}
}

Bonus Question.

Read details of 10 students from user and then print details of all students whose marks are greater
than average marks.

You might also like