-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOULOMBL.C
49 lines (34 loc) · 1.39 KB
/
COULOMBL.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Jason J. Davis
COMP-335L
AAHS Summer '97
Sign off:____________________________ Row #:7
Date: ________________ Due:7/16/1997
CoulLaw.C -- This program will calculate the force of attraction
or force of repulsion between two charged bodies. It is
written in (mostly) ANSI C and demonstrates the ability of
the programmer and the compiler to work together to find
errors in code.
#include <conio.h>
#include <caca_conio.h>
#include <ncurses.h>
*/
#include <stdio.h>
int main()
{
double Q1, Q2, Distance, Force;
const double k = 9000000000.;
/* clrscr(); */
printf("\n\nPlease enter all requested values using basic metric units:");
printf("\n\nPlease enter the charge on the first body (Q1) => ");
scanf("%lf", &Q1);
printf("\nPlease enter the charge on the second body (Q2) => ");
scanf("%lf", &Q2);
printf("\nPlease enter the distance between the two charged bodies => ");
scanf("%lf", &Distance);
Force =k * Q1 * Q2/(Distance*Distance);
/* clrscr(); */
printf("\n\n\n\nWith Q1 = %f Coulombs, and Q2 = %f Coulombs, ", Q1, Q2);
printf("and\nseparated by %f meters, the force between them is %f Newtons",Distance, Force);
/*getch(); wait for user keystroke (when finished reading) */
return 0;
}