31. Which operator is overloaded for a cout object?
32. Which members are inherited but are not accessible in any case?
33. What happens if we run the following code in both C and C++?
#include<stdio.h>
struct STRUCT
{
int a;
int func()
{
printf("HELLO THIS IS STRUCTURE\n");
}
};
int main()
{
struct STRUCT s;
s.func();
return 0;
}
#include<stdio.h>
struct STRUCT
{
int a;
int func()
{
printf("HELLO THIS IS STRUCTURE\n");
}
};
int main()
{
struct STRUCT s;
s.func();
return 0;
}
34. What happens if the following code is compiled on both C and C++?
#include<stdio.h>
struct STRUCT
{
private:
int a;
};
int main()
{
printf("%d\n", (int)sizeof(struct STRUCT));
return 0;
}
#include<stdio.h>
struct STRUCT
{
private:
int a;
};
int main()
{
printf("%d\n", (int)sizeof(struct STRUCT));
return 0;
}
35. What happens if the following program is executed in C and C++?
#include <stdio.h>
int main(void)
{
const int j = 20;
int *ptr = &j;
printf("*ptr: %d\n", *ptr);
return 0;
}
#include <stdio.h>
int main(void)
{
const int j = 20;
int *ptr = &j;
printf("*ptr: %d\n", *ptr);
return 0;
}
36. Which of the following C++ code will give error on compilation?
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
cout<<"Hello World";
return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
std::cout<<"Hello World";
return 0;
}
========================================
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
cout<<"Hello World";
return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
std::cout<<"Hello World";
return 0;
}
========================================
37. What will be the output of the following C++ code?
#include <stdio.h>
int main()
{
const int x;
x = 10;
printf("%d", x);
return 0;
}
#include <stdio.h>
int main()
{
const int x;
x = 10;
printf("%d", x);
return 0;
}
38. In which part of the for loop termination condition is checked?
for(I;II;III)
{IV}
for(I;II;III)
{IV}
Read More Section(Introduction to C plus plus)
Each Section contains maximum 100 MCQs question on Introduction to C plus plus. To get more questions visit other sections.