Skip to content

Instantly share code, notes, and snippets.

@bryanltobing
Last active May 11, 2020 16:16
Show Gist options
  • Save bryanltobing/f19dd180bfc3ac886940599dd6e92c02 to your computer and use it in GitHub Desktop.
Save bryanltobing/f19dd180bfc3ac886940599dd6e92c02 to your computer and use it in GitHub Desktop.
Mencari Energi kinetik menggunakan rumus ketetepan dan data frekuensi
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n, counter;
double penampungNilaiF[n], ek[n];
double f0 = 5000;
cout << "Masukkan banyak n : ";
cin >> n;
for (counter = 0 ; counter < n ; counter++) {
cout << "Nilai f" << counter+1 << "= ";
cin >> penampungNilaiF[counter];
if(penampungNilaiF[counter] < 0) {
cout << "Nilai f" << counter+1 << "= ";
cin >> penampungNilaiF[counter];
}
}
for (counter = 0 ; counter < n ; counter++) {
if(penampungNilaiF[counter] < 5000) {
ek[counter] = 0;
} else {
ek[counter] = ((6.63*pow(10, -34) * penampungNilaiF[counter]) - (6.63*pow(10, -34) * f0)) ;
}
cout << "Nilai Ek" << counter+1 << "= " << ek[counter] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment