Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. void main() {
  5. int temp[5],largest = 0,day = 0,lasttemp=0,firsttemp=0;
  6. printf("Input temperatures for each day in a week:\n");
  7. for (int i = 0; i < 5; i++) {
  8. scanf_s("%d",&temp[i]);
  9. if (temp[i]>largest) {
  10. largest = temp[i];
  11. day = i + 1;
  12. }
  13. if (i == 4) {
  14. lasttemp = temp[i];
  15. }
  16. if (i == 0) {
  17. firsttemp = temp[i];
  18. }
  19. }
  20. printf("\n\nDay\t\ttemperature\n");
  21. for (int i = 0; i < 5; i++) {
  22. printf(" %d\t\t %d\n",i+1,temp[i]);
  23. }
  24. printf("The highest temperature is\\%d\\ in day\\%d\\",largest,day);
  25. printf("\nThe modified temperatures are:\n");
  26. printf("\n\nDay\t\ttemperature\n");
  27. temp[0] = lasttemp;
  28. temp[4] = firsttemp;
  29. for (int i = 0; i < 5; i++) {
  30. printf(" %d\t\t %d\n", i + 1, temp[i]);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement