C Program: Highest Tomato Price in 7 Days Using Array

 #include<stdio.h>

void main()

{

    int price[7], i, max, day;


    printf("Enter tomato prices for 7 days:\n");


    for(i=0;i<7;i++)

    {

        printf("Day %d price: ", i+1);

        scanf("%d",&price[i]);

    }


    max = price[0];

    day = 1;


    for(i=1;i<7;i++)

    {

        if(price[i] > max)

        {

            max = price[i];

            day = i + 1;

        }

    }


    printf("\nHighest tomato price is %d on Day %d", max, day);

}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices