# Power of a lens

Write a program to determine the power of a lens .

Power of a lens is its ability to bend light . For a convex lens, the converging ability is defined by power and in a concave lens, the diverging ability . The diopter ( D ) is the unit of measuring power of a lens .

The power is defined as the reciprocal of the focal length in meters .

D = ( 1 / F )

Here, D is the power in diopter,

F is the focal length in meters.

Examples:

Input : F = 2 Output : D = 0.5 Input : F = 0.2 Output : D = 5

## C++

`// C++ program to determine ` `// the power of a lens ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// function to determine the ` `// power of a lens ` `float` `power(` `float` `focal_length) ` `{ ` ` ` `return` `(1 / focal_length); ` `} ` ` ` `// driver function ` `int` `main() ` `{ ` ` ` `float` `focal_length = 2; ` ` ` `cout << ` `"The power of the lens in diopter is "` ` ` `<< power(focal_length); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to determine ` `// the power of a lens ` `import` `java.io.*; ` ` ` `class` `GFG ` `{ ` ` ` `// function to determine the ` ` ` `// power of a lens ` ` ` `static` `float` `power(` `float` `focal_length) ` ` ` `{ ` ` ` `return` `(` `1` `/ focal_length); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main (String[] args) ` ` ` `{ ` ` ` `float` `focal_length = ` `2` `; ` ` ` `System.out.println(` `"The power of the lens in diopter is "` ` ` `+ power(focal_length)); ` ` ` ` ` `} ` `} ` ` ` `// This code is contributed by Gitanjali. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to determine ` `# the power of a lens ` ` ` `# function to determine ` `# the power of a lens ` `def` `power( focal_length ) : ` ` ` ` ` `return` `( ` `1` `/` `focal_length ) ` ` ` `# driver function ` `focal_length ` `=` `2` `; ` `print` `( ` `"The power of the lens in diopter is "` `, end ` `=` `"") ` `print` `(power(focal_length) ) ` |

*chevron_right*

*filter_none*

## C#

`// C# program to determine ` `// the power of a lens ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// function to determine the ` ` ` `// power of a lens ` ` ` `static` `float` `power(` `float` `focal_length) ` ` ` `{ ` ` ` `return` `(1 / focal_length); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main () ` ` ` `{ ` ` ` `float` `focal_length = 2; ` ` ` `Console.WriteLine(` `"The power of the lens in diopter is "` ` ` `+ power(focal_length)); ` ` ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to determine ` `// the power of a lens ` ` ` `// function to determine the ` `// power of a lens ` `function` `power(` `$focal_length` `) ` `{ ` ` ` `return` `(1 / ` `$focal_length` `); ` `} ` ` ` ` ` `// Driver Code ` ` ` `$focal_length` `= 2; ` ` ` `echo` `"The power of the lens in diopter is "` ` ` `, power(` `$focal_length` `); ` ` ` `// This code is contributed by anuj_67. ` `?> ` |

*chevron_right*

*filter_none*

Output:

The power of the lens in diopter is 0.5

**Source:**

http://www.bbc.co.uk/bitesize/intermediate2/physics/waves_and_optics/power_of_lens/revision/1/

## Recommended Posts:

- Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
- Sum of digits of a given number to a given power
- Program for focal length of a lens
- Number of digits in 2 raised to power n
- Power in Mathematics
- Highest power of 2 less than or equal to given Integer
- Highest and Smallest power of K less than and greater than equal to N respectively
- Find the minimum number to be added to N to make it a power of K
- Check if the number is a Prime power number
- Last digit in a power of 2
- Check whether count of odd and even factors of a number are equal
- Count of ways to make Array sum even by removing only one element
- Find the ratio of LCM to GCD of a given Array
- Maximum absolute difference between distinct elements in an Array

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.