943,819 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1914
  • C++ RSS
Sep 16th, 2006
1

out put of this program

Expand Post »
Predict the output of the following code:

#include < IOSTREAM >
int main()
{
char weekdays [7][10]= {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
cout<<**weekdays; }


Could any one let me know answer and also the explaination if possible
Similar Threads
Reputation Points: 18
Solved Threads: 0
Newbie Poster
Ajay Raj is offline Offline
7 posts
since Sep 2006
Sep 16th, 2006
0

Re: out put of this program

Suggestion: compile and run the program and you will see for yourself what will happen. Of course just getting it to compile without errors will be your first task.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Sep 17th, 2006
1

Re: out put of this program

C++ Syntax (Toggle Plain Text)
  1. #include < IOSTREAM >
Header files are case-sensitive, and those spaces are part of the name, too. Use this instead:
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
Then change
C++ Syntax (Toggle Plain Text)
  1. cout<<**weekdays;
to
std::cout<<**weekdays;
Then it will compile.

The program's output will be S; **weekdays is the same as weekdays[0][0]. The first character of the first string is 'S'.
Reputation Points: 185
Solved Threads: 28
Posting Whiz in Training
dwks is offline Offline
269 posts
since Nov 2005
Sep 17th, 2006
1

Re: out put of this program

Click to Expand / Collapse  Quote originally posted by Ajay Raj ...
Predict the output of the following code:
#include < IOSTREAM >
After removing spaces the header will work as long as you are working on windows which has case-insensitive file system. But, with a cross-platform compiler, usually, case matters.
Last edited by Grunt; Sep 17th, 2006 at 3:50 am.
Reputation Points: 197
Solved Threads: 12
Junior Poster
Grunt is offline Offline
147 posts
since Jul 2006
Sep 17th, 2006
1

Re: out put of this program

As for the usage of header file, when you use include header files the format should be like these
include<iostream.h>
OR

include<iostream>
using namespace std;


Otherwise, it will return error during compilation.

As for the output, it will be like what dwks said.
Reputation Points: 52
Solved Threads: 4
Junior Poster in Training
rinoa04 is offline Offline
84 posts
since Sep 2006
Sep 18th, 2006
1

Re: out put of this program

thanks
Reputation Points: 18
Solved Threads: 0
Newbie Poster
Ajay Raj is offline Offline
7 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Problem with VC++
Next Thread in C++ Forum Timeline: text editor





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC