# Find the concentration of a solution using given Mass and Volume

Given two values **M** and **V** representing the mass of solute and volume of a solution, the task is to calculate the concentration of the solution.

**Examples:**

Input:M = 100.00, V = 500.00

Output:200

Explaination:

C = 1000 * (100 / 500)

The concentration of solution is 200

Input:M = 1.00 V = 1000.00

Output:1

**Approach:** The concentration of a solution is defined as the mass of solute in (gram) per liter of solution.

*Mathematically:*

C = 1000 * (M / V)

Where M = Mass of solute and V = Volume of solution.

Hence, in order to solve the problem, follow the steps below:

- Calculate the concentration of solution using the formula
**C = 1000* (M / V)**. - Print the result.

Below is the implementation of the above approach:

## C++

`// C++ program to find ` `// concentration of a solution ` `// using given Mass and Volume ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to calculate ` `// concentration from the ` `// given mass of solute and ` `// volume of a solution ` `double` `get_concentration(` `double` `mass, ` ` ` `double` `volume) ` `{ ` ` ` `if` `(volume == 0) ` ` ` `return` `-1; ` ` ` `else` ` ` `return` `(mass / volume) ` ` ` `* 1000; ` `} ` ` ` `// Driver Program ` `int` `main() ` `{ ` ` ` `double` `mass, volume; ` ` ` `mass = 100.00; ` ` ` `volume = 500.00; ` ` ` `cout << get_concentration(mass, ` ` ` `volume); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find concentration ` `// of a solution using given Mass ` `// and Volume ` `class` `GFG{ ` ` ` `// Function to calculate ` `// concentration from the ` `// given mass of solute and ` `// volume of a solution ` `static` `double` `get_concentration(` `double` `mass, ` ` ` `double` `volume) ` `{ ` ` ` `if` `(volume == ` `0` `) ` ` ` `return` `-` `1` `; ` ` ` `else` ` ` `return` `(mass / volume) * ` `1000` `; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `double` `mass, volume; ` ` ` `mass = ` `100.00` `; ` ` ` `volume = ` `500.00` `; ` ` ` ` ` `System.out.println(get_concentration(mass, ` ` ` `volume)); ` `} ` `} ` ` ` `// This code is contributed by Ritik Bansal ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find concentration ` `// of a solution using given Mass ` `// and Volume ` `using` `System; ` `class` `GFG{ ` ` ` `// Function to calculate ` `// concentration from the ` `// given mass of solute and ` `// volume of a solution ` `static` `double` `get_concentration(` `double` `mass, ` ` ` `double` `volume) ` `{ ` ` ` `if` `(volume == 0) ` ` ` `return` `-1; ` ` ` `else` ` ` `return` `(mass / volume) * 1000; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `double` `mass, volume; ` ` ` `mass = 100.00; ` ` ` `volume = 500.00; ` ` ` ` ` `Console.Write(get_concentration(mass, ` ` ` `volume)); ` `} ` `} ` ` ` `// This code is contributed by rock_cool ` |

*chevron_right*

*filter_none*

**Output:**

200

**Time Complexity:** O(1)

**Auxiliary Space:** O(1)

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

## Recommended Posts:

- Find the volume of rectangular right wedge
- Concentration of juice after mixing n glasses in equal proportion
- Program to find the Volume of an irregular tetrahedron
- Program to find the Volume of a Triangular Prism
- Program to find the Area and Volume of Icosahedron
- Find maximum volume of a cuboid from the given perimeter and area
- Find Cube Pairs | Set 1 (A n^(2/3) Solution)
- Find Cube Pairs | Set 2 (A n^(1/3) Solution)
- Program to find Surface Area and Volume of Octagonal Prism
- Program to find volume and surface area of pentagonal prism
- Program to Calculate Body Mass Index (BMI)
- Calculate Volume of Dodecahedron
- Program for volume of Pyramid
- Program to calculate volume of Octahedron
- Volume of cube using its space diagonal
- Maximize volume of cuboid with given sum of sides
- Program to calculate volume of Ellipsoid
- Volume of biggest sphere within a right circular cylinder
- Volume of largest right circular cylinder within a Sphere
- Calculate volume and surface area of Torus

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.