Created
November 8, 2024 00:10
-
-
Save jamesy0ung/dfbe198325a44f3a39811443300c8c95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
const int c = { 299792458 }; | |
float findWavelength(float frequency) | |
{ | |
return(c / (frequency * 1000000)); // Convert MHz to Hz and use meters for wavelength | |
} | |
float findDipoleLeg(float wavelength) | |
{ | |
return((wavelength / 2)/2); // Length of each dipole leg is a quarter of the wavelength | |
} | |
int main() | |
{ | |
double frequency; | |
std::cout << "Frequency to dipole calculator\n"; | |
std::cout << "Please enter the frequency in MHz : "; | |
std::cin >> frequency; | |
if (frequency <= 0) { | |
std::cout << "Please enter a valid positive frequency.\n"; | |
return 1; | |
} | |
std::cout << std::endl; | |
double wavelength = findWavelength(frequency); | |
double dipole = findDipoleLeg(wavelength); | |
std::cout << "The length of each leg is: " << dipole << " meters\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment