Questions and Answers
- What is the output of this program?
#include
using namespace std;
int main()
{
typedef int number;
typedef char name;
name n = "Interview Mania";
number P = 12, Q = 25;
number R = P + n;
cout << R;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Error: invalid conversion from ‘const char*’ to ‘let {aka char}’.
Compilation ErrorIn function 'int main()':
7:18: error: invalid conversion from 'const char*' to 'name {aka char}' [-fpermissive]
8:24: warning: unused variable 'Q' [-Wunused-variable]
- What is the output of this program?
#include
using namespace std;
int main()
{
int i;
enum MonthName
{
January,February,March,April,May,June,July,August,September,October,November,December
};
for (i = February; i <= November; i++)
cout << i;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, we are defined the data types as enumerator and printing its value in a order.
- What is the output of this program?
#include
using namespace std;
int main()
{
typedef int number;
number P = 25, Q = 12;
number R = P + Q + P - Q;
cout << R;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, we are manipulating the numbers and printing the result using user-defined data types.
- What does the data type defined by union will do?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Union is used to define the data types of our choice and it will store the data type in one location make them accessible.
- Identify the correct statement.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
By using typedef, we can create a type of pre-existing type only not our own type of data.