Академический Документы
Профессиональный Документы
Культура Документы
defines a variable, called part1, of type structure part. This definition reserves space in memory for part1. How much space?
Exercise:
Use sizeof() to check the size of part1 variable.
//display second variable cout << "Model " << part2.modelnumber; cout << " part " << part2.partnumber; cout << " costs " << part2.cost << endl; return 0; }
Compile the Above code and check what the difference is. If not any difference then Explain why?
Exercise
Create a structure Students with Attributes Full name, Registration No and Marks. Keep record of three students Take input Full name, Registration no and marks from user. Print the values on screen of all 3 students.
Array of Structures
int main() { part part1[10]; part1[0].partnumber=1240; part1[0].modelnumber=6427; part1[0].cost=98.99; return 0; }
Exercise
Modify the Student structure and keeps record of 10 students and take input for each members of part from user. And print with data of Student with all members.
Pointer to Structure
int main() { part* part1; part1->partnumber=1234; part1->modelnumber=2007; part1->cost=129.75; return 0; }
Modify your Student Structure to get the value using get function and assign value using set Function.
Checked By: