1. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
enum cat
{
temp = 7
};
int main()
{
int age = 14;
age /= temp;
cout << "If you were cat, you would be " << age << endl;
return 0;
}
#include <iostream>
using namespace std;
enum cat
{
temp = 7
};
int main()
{
int age = 14;
age /= temp;
cout << "If you were cat, you would be " << age << endl;
return 0;
}
2. For what values of the expression is an if-statement block not executed?
3. Identify the incorrect statements.
int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&&var = 40; //statement 3
int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&&var = 40; //statement 3
4. Pick the right option.
Statement 1: Global values are not initialized by the stream.
Statement 2: Local values are implicitly initialised to 0.
Statement 1: Global values are not initialized by the stream.
Statement 2: Local values are implicitly initialised to 0.
5. Can two functions declare variables(non static) with the same name?
6. Is the size of character literals different in C and C++?
7. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
void a = 10, b = 10;
int c;
c = a + b;
cout << c;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
void a = 10, b = 10;
int c;
c = a + b;
cout << c;
return 0;
}
8. Which is correct with respect to the size of the data types?
9. Which of the following is not one of the sizes of the floating point types?
10. . . . . . . . . have the return type void.
Read More Section(Variables and Data Types in C plus plus)
Each Section contains maximum 100 MCQs question on Variables and Data Types in C plus plus. To get more questions visit other sections.