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

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.

#include < IOSTREAM >

Header files are case-sensitive, and those spaces are part of the name, too. Use this instead:

#include <iostream>

Then change

cout<<**weekdays;

to

[b]std::[/b]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'.

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.

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.

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.