uses parts inventory to demonstrate structures : Struct « Data Type « C++






uses parts inventory to demonstrate structures

   
#include <iostream>   
  using namespace std;   

  struct part{   
     int modelnumber; 
     int partnumber;  
     float cost;      
  };   
  int main(){   
     part part1;      
    
     part1.modelnumber = 6244;
     part1.partnumber = 373;   
     part1.cost = 217.55F;   

     cout << "Model "    << part1.modelnumber;   
     cout << ", part "   << part1.partnumber;   
     cout << ", costs $" << part1.cost << endl;   
     return 0;   
  }
  
    
    
  








Related examples in the same category

1.Defines and uses a struct.Defines and uses a struct.
2.example about structures
3.pointers to structures
4.array of structures
5.demonstrates nested structures
6.demonstrates passing structure by reference
7.demonstrates passing structure as argument