Προγραμματισμός Ι - Θέμα εξετάσεων 16/12/11


/ Published in: C
Save to your folder(s)

Η λύση ενός θέματος εξετάσεων... 16/12/11


Copy this code and paste it in your HTML
  1. #include <stdio.h>
  2.  
  3. struct addressT
  4. {
  5. char street_name[50];
  6. int street_number;
  7. char city[50];
  8. int zip_code;
  9. };
  10.  
  11. struct idT
  12. {
  13. char name[50];
  14. char surname[50];
  15. struct addressT addr;
  16. };
  17.  
  18. struct teleT
  19. {
  20. char wr_no[50];
  21. char cell_no[50];
  22. char fax_no[50];
  23. };
  24.  
  25. struct emT
  26. {
  27. char em_work[50];
  28. char em_home[50];
  29. };
  30.  
  31. typedef struct
  32. {
  33. struct idT ident;
  34. struct teleT tel;
  35. struct emT email;
  36. } personT;
  37.  
  38. int main()
  39. {
  40. personT directory[40];
  41.  
  42. int i;
  43.  
  44. for(i = 0; i <= 1; i++)
  45. {
  46. printf("\nRecord %d: \n", i + 1);
  47.  
  48. printf("\n\tName: ");
  49. scanf("%s", directory[i].ident.name);
  50.  
  51. printf("\n\tSurname: ");
  52. scanf("%s", directory[i].ident.surname);
  53.  
  54. printf("\n\tStreet name: ");
  55. scanf("%s", directory[i].ident.addr.street_name);
  56.  
  57. printf("\n\tStreet number: ");
  58. scanf("%d", &directory[i].ident.addr.street_number);
  59.  
  60. printf("\n\tCity: ");
  61. scanf("%s", directory[i].ident.addr.city);
  62.  
  63. printf("\n\tZip code: ");
  64. scanf("%d", &directory[i].ident.addr.zip_code);
  65.  
  66. printf("\n\tTelephone: ");
  67. scanf("%s", directory[i].tel.wr_no);
  68.  
  69. printf("\n\tCell telephone: ");
  70. scanf("%s", directory[i].tel.cell_no);
  71.  
  72. printf("\n\tFax: ");
  73. scanf("%s", directory[i].tel.fax_no);
  74.  
  75. printf("\n\tE-mail (work): ");
  76. scanf("%s", directory[i].email.em_work);
  77.  
  78. printf("\n\tE-mail (home): ");
  79. scanf("%s", directory[i].email.em_home);
  80. }
  81.  
  82. fflush(stdin);
  83. return 0;
  84. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.