/* * SPDX-FileCopyrightText: 2018 Bruce Cowan <bruce@bcowan.me.uk> * * SPDX-License-Identifier: GPL-3.0-or-later */ #include <stdio.h> #include <stdlib.h> #define C 299792458 #define C2 (C)*(C) int main (int argc, char **argv) { double m; if (argc != 2) { printf ("Input the mass in kg: "); scanf ("%lf", &m); } else { if (sscanf (argv[1], "%lf", &m) != 1) { fprintf (stderr, "Couldn't parse number\n"); return EXIT_FAILURE; } } double e = m * C2; printf ("E = %#.3G J\n", e); return 0; }