C Program to Solve the Fractional Knapsack Problem

This is a C Program to solve fractional knapsack problem. The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a mass and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items.

Here is the source code of the C program to solve fractional knapsack problem. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

#include <stdio.h>

int n =5;/* The number of objects */

int c[10]={12,1,2,1,4};/* c[i] is the *COST* of the ith object; i.e. what