Skip to content
loading...

re: Daily Challenge #187 - Most Sales VIEW POST

FULL DISCUSSION
 

include

int main()
{
int i , a , j , revenue;
char A[15][30];
int B[30];
int C[30];
printf("enter the number of inputs you want to enter :");
scanf("%d" , &a);
printf("enter the name of the items :-\n");
for(i=-1;i<a;i++)
{

    gets(A[i]);

}

for(i=0;i<a;i++)
{
    printf("enter the price of %dth element :\n",i+1);
    scanf("%d" , &B[i]);
}
for(i=0;i<a;i++)
{
    printf("\nenter the quantity of %dth element :\n" , i+1);
    scanf("%d" , &C[i]);
}
 revenue=C[0]*B[0];
 j=0;

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

{
if(i>0)
{
if(C[i]*B[i]>C[i-1]*B[i-1])
{
revenue=C[i]*B[i];
j=i;
}
}

}

printf("%s" , A[j]);

}

code of conduct - report abuse