|
|
PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
int main(int argc, char**argv)
"argc" and argv" are not used in the program right now. if you do not need them int main()
will work fine. If you have some later use you can leave them.const double q = 1.6 * e - 19 * C;
"1.6" is considered a "double" and "C" is defined as a "double", so by the time it is finished you are trying to store a "double" in a "float".id = Is * (e * exp(q * Vd[i]) / (N * k * T));
. Since I initialized the variable "e" to zero the equation becomes id = Is * (0 * exp(q * Vd[i]) / (N * k * T));
, so anything times zero is zero. Also at this point the variable "e" is promoted to a "double" for the calculation, so might as well make it a "double" to begin with.cout<< "Voltage is : " << 'id' <<endl; //prints sentence on screen
. The use of single quotes are for a single character. When there are two or more characters double quotes are used, but I am guessing here that you want no quotes and to use the variable (id).Please enter the value for i: 1.5 Please enter the value for C: 2.5 *.*.*.*.*.*.*.*.*.*.*.*.*.* Voltage VS = 0.00 current ID = Voltage is : 478568477951220708289158855184613376.00 *.*.*.*.*.*.*.*.*.*.*.*.*.* Voltage VS = 0.10 current ID = Voltage is : 7852243681614681939291546106986496.00 *.*.*.*.*.*.*.*.*.*.*.*.*.* Voltage VS = 0.20 current ID = Voltage is : 128837843853439756497919236112384.00 *.*.*.*.*.*.*.*.*.*.*.*.*.* Voltage VS = 0.30 current ID = |
std::cout << std::fixed << std::showpoint << std::setprecision(2);
. The number "2" in setprecision is the number of digits to the right of the decimal point. You can change that to whatever you need.ID=Is { exp[ q Vd / (N k T) ] - 1 } |
|
|
|
|
id = Is * (e, exp (q * Vd[i]) / (N * k * T));
cout << "*.*.*.*.*.*.*.*.*.*.*.*.*.*" << endl;
#include <iterator> // std::advance