Hey guys... had a little problem while trying make this little program that would find the mean of 4 integers... here's what i have so far

#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

int main(void)

{

int X1;
int X2;
int X3;
int X4;
int X;

cout<<"Enter The First Integer value:";
cin>>X1;
cout<<"Enter The Second Integer Value:";
cin>>X2;
cout<<"Enter The Third Integer Value:";
cin>>X3;
cout<<"Enter The Forth Integer Value:";
cin>>X4;

X=(X1+X2+X3+X4)/4.0;

cin.get();cin.get();

return 0;

}

Im asked to enter the 4 integers but then the screen terminates no results. Can help me find what im doing wrong? Thanks.

Recommended Answers

All 3 Replies

To display the value of X you need to put

cout << X << endl;

after X is calculated.

Wow feel stupid... Thanks a lot man

try it out..

#include <iomanip>
#include <iostream>
#include <math>
#include <conio>

int main(void)

{

int X1;
int X2;
int X3;
int X4;
float X;

cout<<"Enter The First Integer value:";
cin>>X1;
cout<<"Enter The Second Integer Value:";
cin>>X2;
cout<<"Enter The Third Integer Value:";
cin>>X3;
cout<<"Enter The Forth Integer Value:";
cin>>X4;

X=(X1+X2+X3+X4)/4.0;

cout << "The result is : " << X << endl ;

 getch();
}
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.