fork download
  1. // Lab 8, Working with structs
  2. // Programmer : Maiar Khattab
  3. // Editor(s) used : Code Blocks 13.12
  4. // Compiler(s) used : Code Blocks 13.12
  5.  
  6. #include<iostream>#include.<stdio.h>
  7. int maint ()
  8. {
  9. printf("prime numbers of 2 to 20: ");
  10. int i, x;
  11. for(i =2; i<=20; i++)
  12. {
  13. for(x=2; x<=i; x++)
  14. {
  15. if(i%x == x + 1)
  16. printf("%d\n", i);
  17. }
  18. }
  19. return 0;
  20. }
  21. using std::cout;
  22. using std::endl;
  23.  
  24. #include<cstdlib>
  25.  
  26. //struct def
  27. struct tod
  28. {
  29. int hour;// the hr , 0-23
  30. int minute;// the min, 0-59
  31. int second;//the sec, 0-59
  32. char descr [32];//the description of the time of day
  33.  
  34. };
  35. //void printTod(const tod&);
  36. int main ()
  37. {
  38. cout << "Lab 8, Working With structs\n";
  39. cout << "Programmer: Maiar Khattab\n";
  40. cout << "Editor(s) used: Code Blocks 13.12\n";
  41. cout << "Compiler(s) used: Code Blocks 13.12\n";
  42. cout << "File: " << __FILE__ << endl;
  43. cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
  44.  
  45. tod theTime[] = {{12,0,0, "noon"},
  46. {0,0,0," midnight"},
  47. {6,00,00," supper "},
  48. {11,30,0,"bedtime"}};
  49.  
  50. for(int i; i <5; i++)
  51. {
  52. char descr [32];
  53. cout << theTime[i].descr << " is " << theTime[i].hour << ':'
  54. << theTime[i].minute << ":" << theTime[i].second << endl;
  55. }
  56. }
  57.  
  58.  
Success #stdin #stdout 0.01s 5436KB
stdin
 
stdout
Lab 8, Working With structs
Programmer: Maiar Khattab
Editor(s) used: Code Blocks 13.12
Compiler(s) used: Code Blocks 13.12
File: prog.cpp
Complied: Mar 20 2023 at 13:18:43

noon is 12:0:0
 midnight is 0:0:0
 supper  is 6:0:0
bedtime is 11:30:0
�G� kwg� is -1322966600:32767:466868224