Write a Program to store temperature of two cities for a week and display it.


#include <stdio.h>

const int CITY = 2;
const int WEEK = 7;

int main()
{
    int temperature[CITY][WEEK];

    for (int i = 0; i < CITY; ++i) 
{
        for(int j = 0; j < WEEK; ++j) 
{
            printf("City %d, Day %d: ", i+1, j+1);
            scanf("%d", &temperature[i][j]);
        }
    }

    printf("\nDisplaying values: \n\n");

    for (int i = 0; i < CITY; ++i) 
{
    for(int j = 0; j < WEEK; ++j)

   {
     printf("City %d, Day %d = %d\n", i+1, j+1, temperature[i][j]);
   
   }
    
}
    return 0;
}
                               


/*
OUTPUT
City 1, Day 1: 33
City 1, Day 2: 34
Displaying values:
City 1, Day 1 = 33
City 1, Day 2 = 34
*/

Comments

  1. sir i want the flowchart for the same above program

    ReplyDelete

Post a Comment