C Program to input the name of the branches, total sales of the company into an array of structures

  Program to input  the name of the branches, total sales of the company into an array of structures, display the branch name and sales of branch who had highest sales.


 

#include<stdio.h>

struct branch

{

char name[25];

long sale;

};

main()

{

struct branch b[100];

int n,i,m;

long max;

clrscr();

printf("\nEnter the no. of Branches");

scanf("%d",&n);

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

{

printf("\nEnter the details of branch %d",i+1);

printf("\nEnter the branch name\n");

scanf("%s",b[i].name);

printf("\nEnter the total sales:\n");

scanf("%ld",&b[i].sale);

}

max=b[0].sale;

m=0;

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

{

if(b[i].sale>max)

{

max=b[i].sale;

m=i;

}

printf("\nBranch with highest Sales:");

printf("\nName:%s",b[i].name);

printf("\nSales: %d\n",b[i].sale);

      }

getch();


}

Post a Comment

Previous Post Next Post