Escribe un programa para determinar la potencia de una lente.
El poder de una lente es su capacidad para doblar la luz. Para una lente convexa, la capacidad convergente se define por la potencia y en una lente cóncava, la capacidad divergente. La dioptría (D) es la unidad de medida de potencia de una lente.
La potencia se define como el recíproco de la distancia focal en metros.
D = ( 1 / F )
Aquí, D es la potencia en dioptrías,
F es la distancia focal en metros.
Ejemplos:
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; }
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.
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) )
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.
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. ?>
Javascript
<script> // Javascript 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 let focal_length = 2; document.write("The power of the lens in diopter is " + power(focal_length)); </script>
Producción:
The power of the lens in diopter is 0.5
Fuente:
http://www.bbc.co.uk/bitesize/intermediate2/physics/waves_and_optics/power_of_lens/revision/1/