By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

what is the output

P: 29
what is the output of the the following code,if the user give"today is thursday" ?


const int LENGTH = 18;
char message_[LENGTH];
std::cout<<"which day is today?"<<std::endl;
std::cin>>message_;
std::cout<<message_<<std::endl;
Jun 11 '07 #1
Share this Question
Share on Google+
7 Replies


P: 29
what is the output of the following code?



int found = 0, count = 5;
if( ! found | | --count == 0)
std::cout<<"danger"<<std::endl;
std::cout<<"count = "<<count<<std::endl;
Jun 11 '07 #2

sicarie
Expert Mod 2.5K+
P: 4,677
what is the output of the following code?



int found = 0, count = 5;
if( ! found | | --count == 0)
std::cout<<"danger"<<std::endl;
std::cout<<"count = "<<count<<std::endl;
Did you try putting this into a compiler?
Jun 11 '07 #3

RedSon
Expert 5K+
P: 5,000
what is the output of the following code?



int found = 0, count = 5;
if( ! found | | --count == 0)
std::cout<<"danger"<<std::endl;
std::cout<<"count = "<<count<<std::endl;
Please do not double post very similar questions. You can create one thread per question.

-MODERATOR
Jun 11 '07 #4

P: 29
[quote=sicarie]Did you try putting this into a compiler?

yes,i could not get the result.
Jun 12 '07 #5

weaknessforcats
Expert Mod 5K+
P: 9,197
what is the output of the the following code,if the user give"today is thursday" ?


const int LENGTH = 18;
char message_[LENGTH];
std::cout<<"which day is today?"<<std::endl;
std::cin>>message_;
std::cout<<message_<<std::endl;
The result is: today

The >> operator stops at the first whitespace character so you only get the word today.

If you are trying to get today is Thursday, then you need to get the entire string. Use cin.getline() for this.
Jun 12 '07 #6

P: 29
The result is: today

The >> operator stops at the first whitespace character so you only get the word today.

If you are trying to get today is Thursday, then you need to get the entire string. Use cin.getline() for this.
thankx,
how did u implement "const int LENGTH = 18" and
"char message_[LENGTH]"
Jun 12 '07 #7

weaknessforcats
Expert Mod 5K+
P: 9,197
how did u implement "const int LENGTH = 18" and
"char message_[LENGTH]"
I'm not sure what you mean. I just looked at your code.
Jun 14 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.