Skip to content

Instantly share code, notes, and snippets.

@sams96
Created October 4, 2015 19:49
Show Gist options
  • Save sams96/cf07915224f0a3a0fc29 to your computer and use it in GitHub Desktop.
Save sams96/cf07915224f0a3a0fc29 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
double calcE(double m, double c) {
double e;
double c2;
c2 = pow(c, 2);
e = (m * c)/10;
return e;
}
void printE(double m, double c) {
double e = calcE(m, c);
printf("The energy available from an object of mass %d is %d.2 PJ\n",
m, e);
return ;
}
int main() {
double c = 2.99792458;
printE(1, c);
printE(3.142, c);
printE(10, c);
printE(42, c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment