out put of this program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 7
Reputation: Ajay Raj is an unknown quantity at this point 
Solved Threads: 0
Ajay Raj Ajay Raj is offline Offline
Newbie Poster

out put of this program

 
1
  #1
Sep 16th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,442
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1474
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: out put of this program

 
0
  #2
Sep 16th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: out put of this program

 
1
  #3
Sep 17th, 2006
  1. #include < IOSTREAM >
Header files are case-sensitive, and those spaces are part of the name, too. Use this instead:
  1. #include <iostream>
Then change
  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'.
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 147
Reputation: Grunt has a spectacular aura about Grunt has a spectacular aura about 
Solved Threads: 12
Grunt's Avatar
Grunt Grunt is offline Offline
Junior Poster

Re: out put of this program

 
1
  #4
Sep 17th, 2006
Originally Posted by Ajay Raj View Post
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.
The key to eliminating bugs from your code is learning from your mistakes.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: out put of this program

 
1
  #5
Sep 17th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 7
Reputation: Ajay Raj is an unknown quantity at this point 
Solved Threads: 0
Ajay Raj Ajay Raj is offline Offline
Newbie Poster

Re: out put of this program

 
1
  #6
Sep 18th, 2006
thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC