So i wanted to build a program in which scientific sums are solved along with the steps .I tried but i failed .
Here is the code ~

#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <conio.h>


using namespace std;
int main(){
    int reply;
int u ,v ,t;
int a = v-u/t;
cout << "1.Press 1 to find out acceleration" << endl;
cout << "2.Press 2 to find out velocity time relation"<< endl;
cout << "3.Press 3 to find out postive time relation" << endl;
cout << "4.Press 4 to find out positive velocity relation" << endl;
cin >> reply;

if (reply==1){

cout <<"enter your initial velocity(u)" << endl;
cin >> u;
cout << "enter your final velocity(v)" << endl;
cin >> v;
cout << "enter your time(t)" << endl;
cin >> t;
cout << "The formula is - a=v-u/t " << endl;
cout << "Therefore " << "a=" << v << "-" << u << "/" << t << endl;
cout << "=" << "a=" << v-u << "/" << t << endl;
cout <<"=" << a << endl;
}

system("pause");
}

Its incomplete ,but even the first code to find out the acceleration is not working .

For eg ~ When i enter the intial velocity as 20 and final velocity as 20 and time as 10 it shows up correctly up to " 0/10 "
But when printing the final result that is "v-u/t" it fails terribly .
A long number like "20001002" something comes up .
I am still a beginner but would like to know how to fix this issue .
Help would be greatly appreciated .

Your formula needs to be computed inside a function so at line 11 you have a big error as you are trying to initialize an integer variable with the result of an operation of three other uninitialized variables.

//ex
float density(float mass,float volume)  {
   return mass/volume;
 }

Your formula needs to be computed inside a function so at line 11 you have a big error as you are trying to initialize an integer variable with the result of an operation of three other uninitialized variables.

//ex
float density(float mass,float volume)  {
   return mass/volume;
 }

Umm,could you show what editing should be done in my program ?

I added

int printAcceleration(int z , int x , int y){
return z-x/y;
}

outside int main()

and

cout <<"=" << printAcceleration(u,v,t) << endl;

instead of " a "

But still when i try to put the two velocity's as 20 ,20 and time as 10 the ans is 18 .
i would really appreciate if you could edit my program and point out my mistake .

commented: Of course. You didn't get it the first time so you need us to finish your homework. Really lame!!! -4

You need take into account the operator precedence rules.I believe you meant (z-x)/y.

You need take into account the operator precedence rules.I believe you meant (z-x)/y.

Excellent answer ,now its working perfectly ,Thank you !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.