hi,please help me with this program ,iwant it to print values of x not x

#include <iostream>
using namespace std;
int main()
{
int x = 5;
while(x < 7)
{
    std::cout<<" value of x"<<'\n';
x=x+1;
}
    while(x > 7)
    {
        std::cout<<" value of x"<<'\n';
        x=x-2;
        }
return 0;
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

So tell it to. You're only going to get output if you tell it to generate output and what to output.

int someValue = 10;
cout << "The value of someValue is: " << someValue << endl;

Edited 5 Years Ago by Fbody: n/a

may be you don't understand me,i want the program to show the values of x on the screan dump

I understand perfectly. It's not going to output the value of a variable unless you include that variable in the output statement:

#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main() {
  int someValue = 10;
  cout << "The value of someValue is: " << someValue << endl; //pay close attention to this line
  cin.get();
  return 0;
}

Edited 5 Years Ago by Fbody: n/a

#include <iostream>
using std::endl;
using std::cin;
int main()
{
int x = 5;
while(x < 7)
{
std::cout<<" value of x."<<x<<'\n';
x=x+1;
}
while(x > 7)
{
std::cout<<" value of x."<<x<<'\n';
x=x-2;
cin.get();
}
return 0;
}

i think may there is problem with braces because error type is one or more multiple files used

What you've posted compiles and runs properly. If you can't compile, you'll have to check your compilation settings.

It is okay thanks,but what iwas looking for is for the program to produce output like this:567753

#include <iostream>
using std::endl;
using std::cin;
int main()
{
int x = 5;
while(x < 7)
{
std::cout<<" value of x."<<x<<'\n';
x=x+1;
}
while(x > 2)
{
std::cout<<" value of x."<<x<<'\n';
x=x-2;
cin.get();
}
return 0;
}

Then take out all the "fluff" you've put in your output statements. You're going to get as much or as little as you put into the statement, add or remove as necessary to get what you want.

And please start using [code] ...code tags... [/code]. I haven't said anything, but you have enough posts you should know by now.

This article has been dead for over six months. Start a new discussion instead.