Sei sulla pagina 1di 11

Name of Lecturer: Miss T Chambers

Name of Laboratory Technologist: Mr. M Wright


Course Name: Programming in Engineering
Student Name: Horace Royal
ID Number: 1604190
Date Given: January 29, 2018
Question #1
Write “State the coefficients of your quadratic equation”
Read (a,b,c)

d= pow(b,2) -(4*a*c)
x1 = (-b+ sqrt(d))/(2*a)
x2 = (-b - sqrt(d))/(2*a)

If (a=0)
Write “This equation is linear please try again”
Else
If (d>0)
Write “Two real and district roots”
Write X1, X2
End if
If(d<0)
Write “Error the roots are complexed”
End if
End if
Question #3

Write “Enter C to calculate net current”


Write “Enter SC to calculate saturated current”
Write “Enter V to calculate applied voltage”
Read val_cal
If val_cal=“C”
Write “enter the applied voltage,saturation current and the junction temperature
values’’
Read V, Io,T
I = Io*(exp((q*V)/(k*T))-1)
Write I
Else if val_cal=“SC”
Write “ enter the applied voltage net current and the junction temperature values”
Read V,I,T
Io = I/(exp((q*V)/(k*T))-1)
Write Io
Else
Write “enter the net current, net current and the junction temperature values”
Read I,T, Io
V=((k*T)/q)*log((I/Io)+1)
Read V
End if
Question #1

Set n to 0
Set x[10] to {}
Set S to 125348
x[0]=6*pow(10,2)
do {x[n+1]=0.5*(x[n]+(s/x[n]));
n++}
while (x[n] != x[n-1])
Write “The square of S is
Write S
Write X[n]
Question #1

#include<iostream>
#include<math.h>

using namespace std;

int main()
{
long double Io,T,V,I;
float q,k;
int cal;
q= 1.6*pow(10,-19);
k=1.38*pow(10,-23);

cout<<" select 1 to calculate net current\n";


cout<<" select 2 to calculate saturation current\n";
cout<<" select 3 to calculate applied voltage\n";
cin>> cal;

if (cal=1)
{

cout<<" enter the applied voltage,saturation current and the junction temperature
values\n";
cin>> V;
cin>> Io;
cin>>T;
I = Io*(exp((q*V)/(k*T))-1);
cout<<I<<endl;}

else if (cal=2)
{
cout<<" enter the applied voltage,net current and the junction temperature values\n";
cin>> V;
cin>> I;
cin>>T;

Io = I/(exp((q*V)/(k*T))-1);
cout<<Io<<endl;

else if(cal=3)
{

cout<<" enter the net current,net current and the junction temperature values\n";
cin>> I;
cin>> Io;
cin>>T;

V=((k*T)/q)*log((I/Io)+1);
cout<< V<<endl;
return 0;
}

Question #1
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
double a,b,c;
float x1,x2,d;
cout<< " the coefficients of your quadratic equation\n";
cin>>a;
cin>>b;
cin>>c;
d= pow(b,2) -(4*a*c);
x1 = (-b+ sqrt(d))/(2*a);
x2 = (-b - sqrt(d))/(2*a);

if(a==0)
{
cout<<" this equation is linear\n\n";
} else
{
if(d==0)
{
cout<<" repeated real number solution\n";
cout<<"first root is \n"<<x1 <<"\n the second root
is\n"<<x2<<"\n\n";
}
else
{
if(d>0)
{
cout<<" two real distinct number solution\n";
cout<<"first root is \n"<<x1 <<"\n the second root is\n"<<x2<<"\n\n";
}
else{
if(d<0)
{
cout<<" error!! these roots are complexed\n\n";
}

}
}
}
return 0;
}
Question #2

#include<iostream>
#include<math.h>

using namespace std;

int main()
{
int n=0;
double x[10]={};
float s=125348;
x[0]=6*pow(10,2);
do
{
x[n+1]=0.5*(x[n]+(s/x[n]));
n++;
} while(x[n] != x[n-1]);
cout<< "the square of "<<s<<" is \n";
cout<< x[n];
return 0;
}

Potrebbero piacerti anche