I am doing IT as a hobby.
I thought to changing my code variable type on those variables M,C,T,Q.
It gave me good reaction.When I use int it shows 0 as answer when it has to show answer<0.Now is is ok.
Code: Select all
//calculate Q=MCT
#include<iostream>
using namespace std;
int main(){
float m,c,t,q,z;
char x;
cout<<"We are goig to calculate Q=MCT"<<endl<<endl;
cout<<"Enter what you wanna calculate Q or M or C or T -"<<endl<<endl;
cin>>x;
if(x=='q'){
cout<<"enter your dimentions - "<<endl;
cout<<"M - ";
cin>>m;
cout<<endl<<"C - ";
cin>>c;
cout<<endl<<"T - ";
cin>>t;
q=m*c*t;
cout<<endl<<"Your anser for Q - "<<q;
cout<<endl<<"thank you for using this program ";
system("pause");
return 0;
}
else if(x=='m'){
cout<<"enter your dimentions - "<<endl;
cout<<"Q - ";
cin>>q;
cout<<endl<<"C - ";
cin>>c;
cout<<endl<<"T - ";
cin>>t;
z=(c*t);
m=q/z;
cout<<endl<<"Your anser for M - "<<m;
cout<<endl<<"thank you for using this program ";
system("pause");
return 0;
}
else if(x=='c'){
cout<<"enter your dimentions - "<<endl;
cout<<"Q - ";
cin>>q;
cout<<endl<<"M - ";
cin>>m;
cout<<endl<<"T - ";
cin>>t;
z=(m*t);
c=q/z;
cout<<endl<<"Your anser for c - "<<c;
cout<<endl<<"thank you for using this program ";
system("pause");
return 0;
}
else if(x=='t'){
cout<<"enter your dimentions - "<<endl;
cout<<"Q - ";
cin>>q;
cout<<endl<<"M - ";
cin>>m;
cout<<endl<<"C - ";
cin>>t;
z=(m*c);
t=q/z;
cout<<endl<<"Your anser for T - "<<t;
cout<<endl<<"thank you for using this program ";
system("pause");
return 0;
}
system("pause");
return 0;
}