*
// A salesman has n things to sale. The cost price of all n things is different out of which p things
// he is selling on m% profit and n-p things he is going to sell on x% loss. Find his net profit or loss.
#include<stdio.h>
int main()
{
int n,i,p,m,x,profit=0,loss=0,total;
printf("Enter size of array : ");
scanf("%d",&n);
int items[n];
printf("\n Enter Price of Each product :");
for( i=0;i<n;i++)
{
printf("\nProduct %d of Rs: ",i+1);
scanf("%d",&items[i]);
}
printf("\n Enter count of profit products : ");
scanf("%d",&p);
printf("\npercantage of profit : ");
scanf("%d",&m);
printf("\npercantage of loss : ");
scanf("%d",&x);
for(i=0;i<p;i++)
{
profit += (m* items[i])/100;
}
for(i=p;i<n;i++)
{
loss += (x* items[i])/100;
}
total = profit - loss;
if(total>0)
{
printf("\n Total profit : %d",total);
}
else if(total<0){
printf("\nTotal loss : %d ",total);
}
else{
printf("\nNo profit no loss");
}
return 0;
}
Comments
Post a Comment