please i will like someone to dymystify the use of the standard input for me.Anytime i call the function the output is always the cout that precedes it while subsequent cout expression(s) after it will not be outputed.e.g:
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"please enter an integer value:50"<<endl;
cin>>a;
cout<<"the value you entered is"<<a;
cout<<"and its double is"<<a*2<<"\n";
return 0;
}
The above code will only output:please enter an integer value:50.while:the value you entered is...and its double is... were not outputed.what went wrong.
after addind cout.flush() or endl instead of '\n' the output remains the same.pls help me out.
i appreciate you all but the question is:where will the integer 50 be input?because after running what btripp suggested i did not get the output he suggested and i figure the location of integer 50 might be responsible.thanks.
I have an idea of what you are trying to do. Why do you have the number 50 in the cout?? I think "50" is the number you actually want to enter right?? if so do this..
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"please enter an integer value: "<<endl; // see i removed 50 from the output
cin>>a; // when u call cin it is waiting for you to input an integer, and then it stores it in the variable "a"
cout<<"the value you entered is "<<a;
cout<<" and its double is "<<a*2<< endl; // also make this endl it is better than new line
system("pause"); // also add this code to pause the screen so you can see your code on the screen
return 0;
}
the following output will look like this on the screen if i were to input 50 as my number
please enter an integer value:
50
the value you entered is 50 and its double is 100
Please press enter to continue...
yea i figured it was for homework purposes, my fault for creating security issues in his project. Was my other information good advice though. Im new to the forums.