Guest User

Untitled

a guest
Nov 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. typedef struct car{
  7. int miles;
  8. char make[20];
  9. char model [20];
  10. int year;
  11. float price;
  12. }CAR;
  13.  
  14. void addOne (CAR*);
  15.  
  16. int main (void)
  17. {
  18. CAR special;
  19. addOne(&special);
  20.  
  21. printf("MILES: %d\n", special.miles);
  22. printf("MAKE: %s\n", special.make);
  23. printf("MODEL: %s\n", special.model);
  24. printf("YEAR: %d\n", special.year);
  25. printf("PRICE: %.2f\n", special.price);
  26. //printf("%s\n", special.make);
  27. system("pause");
  28. return 0;
  29. }
  30. /*===================================================
  31. This function
  32. Pre:
  33. Post:
  34. */
  35. void addOne(CAR* spe)
  36. {
  37. printf("Enter miles:\n ");
  38. scanf("%d", &spe->miles);
  39. printf("Miles: %d\t\n", (*spe).miles);
  40.  
  41. printf("Enter make: \n");
  42. scanf("%s", &spe->make);
  43. printf("Make: %s\t\n", (*spe).make);
  44.  
  45. printf("Enter model: \n");
  46. scanf("%s", &spe->model);
  47. printf("Model: %s\t\n", (*spe).model);
  48.  
  49. printf("Enter year: \n");
  50. scanf("%d", &spe->year);
  51. printf("Year: %d\t\n", (*spe).year);
  52.  
  53. printf("Enter price: \n");
  54. scanf("%f", &spe->price);
  55. printf("Price: %.2f\t\n\n", (*spe).price);
  56. return;
  57. }
Add Comment
Please, Sign In to add comment