donmike25

struct car

Dec 4th, 2013
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. struct Car{
  5. // Provide structure definiton for Car here}
  6. char name[20];
  7. float price;
  8. };
  9.  
  10. void UpdateA (struct Car data[]);
  11. void DisplayA (struct Car data[]);
  12.  
  13. main(){
  14. struct Car Proton[3];
  15. //Call function UpdateA and DisplayA here
  16. UpdateA(Proton);
  17. DisplayA(Proton);
  18.  
  19. return 0;
  20. }
  21.  
  22. void UpdateA(struct Car data[]){
  23. //update table A data here
  24. strcpy(data[0].name,"Saga");
  25. data[0].price=42000;
  26.  
  27. strcpy(data[1].name,"Waja");
  28. data[1].price=60000;
  29.  
  30. strcpy(data[2].name,"Persona");
  31. data[2].price=55000;
  32. }
  33.  
  34. void DisplayA(struct Car data[]){
  35. //Display the table A on screen
  36. int i;
  37. for(i=0;i<3;i++)
  38. printf("Model=%s price=%.f\n",data[i].name,data[i].price);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment