diff --git a/3rd Sem (Data Structure)/array.c b/3rd Sem (Data Structure)/array.c new file mode 100644 index 0000000..b22de75 --- /dev/null +++ b/3rd Sem (Data Structure)/array.c @@ -0,0 +1,121 @@ +#include +#include +struct Student +{ +char name[25]; + int usn; + int m1,m2,m3; +}; +char filename[15]; +int n; +struct Student s; +void Insert() +{ +FILE *fp; +int i; +printf("\n\n\tEnter how many Records: "); +scanf("%d",&n); +fp=fopen(filename,"w"); +if(fp==NULL) printf("\n\n\tError in Creating the File...."); +else +for(i=0;i +int main() +{ +intlocks,stocks,barrels,sales,flag=0; +float commission; +printf("Enter the total number of locks\n"); +scanf("%d",&locks); +printf("Enter the total number of stocks\n"); +scanf("%d",&stocks); +printf("Enter the total number of barrels\n"); +scanf("%d",&barrels); +if((locks<=0) || (locks>70)) +{ +flag=1; +printf("Locks Out of Range\n"); +} +if((stocks<=0) || (stocks>80)) +{ +flag=1; +printf("Stocks Out of Range\n"); +} +if((barrels<=0) || (barrels>90)) +{ +flag=1; +printf("Barrels Out of Range\n"); +} +if(flag == 1) +{ +printf("Invalid input\n"); +return 0; +} +sales= locks*45 + stocks*30 + barrels*25; +if(sales <= 1000) +{ +commission = 0.10 * sales; +} +else if(sales <= 1800) +{ +commission = 0.10 * 1000; +commission = commission + (0.15 * (sales - 1000)); +} +else +{ +commission = 0.10 * 1000; +commission = commission + (0.15 * 800); +commission = commission + (0.20 * (sales - 1800)); +} +printf("Total sales: %d and Commission: %f\n",sales,commission); +return 0; +}