0

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.

Edited by Narue: Added code tags, not that it helped without formatting.

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by brainfo
0

To display the value of X you need to put

cout << X << endl;

after X is calculated.

0

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();
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.