Alright so lets create a quick program for what is know as OHM’s law.
Now I am going to make this one really basic. Perhaps in the near future I will add more functionality. Here we go.
#include
#include
using namespace std;
int main ()
{
double resistance; /* Stores resistance entered by the user */
double voltage; /* Stores volatage entered by the user */
double current; /* Stores current after calculation */
double power; /* Stores the power ofter calulation */
cout << "Enter the resistance of the resistor: ";
cin >> resistance;
cout << "Enter the voltage across the resistor: ";
cin >> voltage;
/* Calculate current */
current = voltage/resistance;
/* Calculate power */
power = voltage * current;
/* Output the area */
cout << "For a resister of " << resistance << "ohms and " << voltage << "volts across it," << endl;
cout << setprecision(3); /* Sets my precision in decimal places */
cout << fixed; /* This makes it so that my output is not in scientific notation */
cout << "the current is " << current << "amps and the power is " << power << "watts." << endl;
system ("PAUSE"); /* Normally not used, for display purposes only */
return (0);
}
Ok so this a very basic program here. It does what I want it to do. I will add more functionality later so that it can make some kind of decisions later.
You know...like a smart program. One of the first of it's kind lol. Well there you have it. Take that!


Recent Comments