Hello all,
I am a college freshman and about a week ago, I started coding for the very first time as I am taking an introduction to C programming course. For my first project (besides the basic "hello world"), I decided to build a program that could take a user inputted LCN and convert it to its respective frequency and vice versa. This is something I had to manually calculate in the past. Hopefully no one else has already created this tool
I figured I would share it here with you all to take a look at, constructively critique, and possibly use for your own purposes. As I said, I am a complete novice, so I know my code probably has some bugs and could look prettier, but here it is. The .exe files can (hopefully) be found here for anyone that wants to try it out: LCN calculators - Google Drive
Let me know if there are any issues with accessing or running the files.
*Note: the second program outputs, say, "348.000000" instead of just "348" for the LCN. If anyone knows how I can remove the ".000000" please let me know!
LCN-to-frequency:
Frequency-to-LCN:
I am a college freshman and about a week ago, I started coding for the very first time as I am taking an introduction to C programming course. For my first project (besides the basic "hello world"), I decided to build a program that could take a user inputted LCN and convert it to its respective frequency and vice versa. This is something I had to manually calculate in the past. Hopefully no one else has already created this tool
I figured I would share it here with you all to take a look at, constructively critique, and possibly use for your own purposes. As I said, I am a complete novice, so I know my code probably has some bugs and could look prettier, but here it is. The .exe files can (hopefully) be found here for anyone that wants to try it out: LCN calculators - Google Drive
Let me know if there are any issues with accessing or running the files.
*Note: the second program outputs, say, "348.000000" instead of just "348" for the LCN. If anyone knows how I can remove the ".000000" please let me know!
LCN-to-frequency:
C:
#include <stdio.h>
int main(void)
{
double inputLcn;
double resultFreq;
while(1) {
printf("\nPlease enter LCN: \n");
scanf("%lf", &inputLcn);
if ((inputLcn > 0) && (inputLcn <= 400)) {
resultFreq = 450 + (inputLcn - 1) * 0.0125;
printf("The frequency is: %lf MHz\n", resultFreq);
}
else if ((inputLcn >= 401) && (inputLcn <= 800)) {
resultFreq = 460 + (inputLcn - 401) * 0.0125;
printf("The frequency is: %lf MHz\n", resultFreq);
}
else {
printf("This LCN is used for a non-standard frequency. No frequency can be reported\n");
}
}
return 0;
}
Frequency-to-LCN:
C:
#include <stdio.h>
int main(void)
{
double inputFreq;
double resultLcn;
while(1) {
printf("\nPlease enter frequency: \n");
scanf("%lf", &inputFreq);
if ((inputFreq >= 450.0) && (inputFreq < 455.0)) {
resultLcn = ((inputFreq - 450) / 0.0125) + 1;
printf("The LCN is: %lf\n", resultLcn);
}
else if ((inputFreq >= 460.0) && (inputFreq < 465.0)) {
resultLcn = ((inputFreq - 460) / 0.0125) + 401;
printf("The LCN is: %lf\n", resultLcn);
}
else {
printf("This frequency uses a non-standard LCN. No LCN can be reported\n");
}
}
return 0;
}