Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- void main() {
- int temp[5],largest = 0,day = 0,lasttemp=0,firsttemp=0;
- printf("Input temperatures for each day in a week:\n");
- for (int i = 0; i < 5; i++) {
- scanf_s("%d",&temp[i]);
- if (temp[i]>largest) {
- largest = temp[i];
- day = i + 1;
- }
- if (i == 4) {
- lasttemp = temp[i];
- }
- if (i == 0) {
- firsttemp = temp[i];
- }
- }
- printf("\n\nDay\t\ttemperature\n");
- for (int i = 0; i < 5; i++) {
- printf(" %d\t\t %d\n",i+1,temp[i]);
- }
- printf("The highest temperature is\\%d\\ in day\\%d\\",largest,day);
- printf("\nThe modified temperatures are:\n");
- printf("\n\nDay\t\ttemperature\n");
- temp[0] = lasttemp;
- temp[4] = firsttemp;
- for (int i = 0; i < 5; i++) {
- printf(" %d\t\t %d\n", i + 1, temp[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement