Q#2 • Write a program that defines the structure "part", having three members: Model number (int) Part number (int) Cost (float) Assign the value to the members of the structure. Define two structure variables part1 and part2. Initialize part1, print out the values of its members, assign part1 to part2, and print out is members.
1
Expert's answer
2012-10-17T09:37:25-0400
#include<iostream> using namespace std;
struct part{ int mod_num, part_num; float cost; } part1, part2;
void main(){ cout<<"enter the model number: "; cin>>part1.mod_num; cout<<"enter the part number: "; cin>>part1.part_num; cout<<"enter the cost: "; cin>>part1.cost; part2 = part1; cout<<part2.mod_num<<" "<<part2.part_num<<" "<<part2.cost<<"\n"; system("pause"); }
Comments
Leave a comment