Predict the output of the following code:

#include < IOSTREAM >
int main()
char weekdays [7][10]= {
cout<<**weekdays; }

Could any one let me know answer and also the explaination if possible

Recommended Answers

All 5 Replies

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




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

using namespace std;

Otherwise, it will return error during compilation.

As for the output, it will be like what dwks said.


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.