I want to create an array which displays the element that many times as the entered frequency. I wrote the following code
printf("Enter the number of 5 kg cartons: ");
scanf("%d",&c5);
printf("Enter the number of 10 kg cartons: ");
scanf("%d",&c10);
int x=c5+c10;
int cartons[x],i,j;
for(i=0;i<c5;i++){
cartons[i]= 5;
for(j=i;j<c10;j++){
cartons[j]= 10;
}
}
I want the Out put to be the following if I give c5 and c10 the value 2: 5 5 10 10