1

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

5
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by Ajay Raj
0

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.

1
#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'.

1

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.

1

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.